Merge lp:~csurbhi/partman-btrfs/testing-subvol into lp:~ubuntu-core-dev/partman-btrfs/ubuntu
Status: | Merged |
---|---|
Merged at revision: | 55 |
Proposed branch: | lp:~csurbhi/partman-btrfs/testing-subvol |
Merge into: | lp:~ubuntu-core-dev/partman-btrfs/ubuntu |
Diff against target: |
103 lines (+49/-1) 3 files modified
debian/changelog (+7/-0) fstab.d/btrfs (+24/-1) mount.d/btrfs (+18/-0) |
To merge this branch: | bzr merge lp:~csurbhi/partman-btrfs/testing-subvol |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson | Approve | ||
Review via email: mp+47975@code.launchpad.net |
This proposal supersedes a proposal from 2011-01-28.
Description of the change
Our aim is to be able to do automatic snapshots of home and / separately. Having a separate subvolume for / and another subvolume for /home allows us to take snapshots of these subvolumes independently.
Note that we have two basic scenarios:
1) /home is a separate partition and is mounted on dir home in /
2) /home is not a separate partition and is simply a dir under /
We need to basically achieve the following through the installer:
1) create the subvolume @ for / and @home for /home (just a naming convention discussed)
2) mount @ on / and mount @home on /home
3) prepare fstab such that every time the subvolumes are mounted.
====
Code:
1) fstab.d/btrfs checks if /home is a separate partition or not. If / is btrfs formatted then it adds an entry to mount the subvol=@home on /home even if /home is not a separate partition.
2) In case /home is a separate btrfs partition then it adds an entry to mount the subvolume=@home on /home.
3) Only when both / and /home are not btrfs formatted, then no entry corresponding to @home is added.
mount.d/btrfs gets the mountpoints by reading the fstab.d/btrfs and so it always gets to mount /home in both the cases discussed above.
======
Testing:
1) have tested the code for the following cases:
a) /home:btrfs /:btrfs
b) no separate /home, /:btrfs
c) /home:ext2 /:btrfs
d) /home:btrfs, /:ext2
e) /home:ext2 /:ext2
f) no separate /home, /:ext2
====
Please do let me know what you think of it! Thanks!
Could you propose this for merging into
lp:~ubuntu-core-dev/partman-btrfs/ubuntu instead, rather than the
upstream lp:partman-btrfs? That way I won't see the changes from
5ubuntu1 in the review diff.
On Fri, Jan 28, 2011 at 02:14:14PM -0000, Surbhi Palande wrote:
> Code:
> 1) fstab.d/btrfs checks if /home is a separate partition or not. If / is btrfs formatted then it adds an entry to mount the subvol=@home on /home even if /home is not a separate partition.
> 2) In case /home is a separate btrfs partition then it adds an entry to mount the subvolume=@home on /home.
> 3) Only when both / and /home are not btrfs formatted, then no entry corresponding to @home is added.
Your general approach looks fine to me.
> if [ "$mountpoint" = / ]; then
> + if [ $home_found = unknown ]; then
In shell, a good rule of thumb is to always put "" around any word
containing $ unless there's a specific reason not to. It doesn't matter
in practice here because the value of home_found is always a single
word, but it would be good style to use "$home_found" instead (and
similar for other $-expansions in your branch). I know this guideline
isn't followed universally in the installer, but I'd like to see at
least new code following it.
(Good reason not to put "" around a word containing $ are when you
explicitly want word splitting to be performed, or in the first argument
to 'case' which is never word-split so doesn't require quoting.)
More generally, I think there may be an ordering problem here. You're
iterating in disk/partition order, so this will go wrong if it happens
that the /home partition is on an earlier disk or partition than /.
This probably won't be the common case but we should still deal with it.
I suggest that you should make this file have two loops, both with
roughly the same form (don't worry about optimising away multiple calls
to 'open_dialog PARTITIONS' etc. - this code is run a few times, but it
isn't particularly time-critical). The first should just check whether
there's a partition with mountpoint=/home. The second should be more or
less what was there before your change, but with the extra changes to
options and home_options. That way, it will work whichever way round
the partitions happen to be.
> - mount -t btrfs ${options:+-o "$options"} $fs /target$mp || exit 1 ${options% ,subvol= *} ${options: +"-o $options"}
> + options=
> + options=
I'd find it clearer to put the quotes around the whole $-expansion here
(and similarly below), i.e.:
options= "${options: +-o $options}"
This means you don't have to wonder whether it's quoted that way because
the "" are supposed to end up in the value of options.
> + mkdir -p /target$mp
You can skip this - mount.d scripts are called from target/ finish. d/mount_ partitions, which always creates the
partman-
directory first.
> + mount -t btrfs $options $fs /target$mp || exit 1 ${options: +"$options, subvol= @"} ${options: ="-o subvol=@"}
> + case $mp in
> + /)
> + btrfs subvolume create /target$mp/@
> + umount /target$mp
> + options=
> + options=
Using := here is odd. "${options:=-o subvol=@}" assigns to options, and
then you assign the result of that to options again ...
The repe...