Date: Fri, 12 Mar 2004 14:22:21 -0500 (EST) From: Jerry McAllister <jerrymc@clunix.cl.msu.edu> To: list-freebsd@fsck.net (Eugene Lee) Cc: freebsd-questions@freebsd.org Subject: Re: resizing partitions in the same slice Message-ID: <200403121922.i2CJMLa19763@clunix.cl.msu.edu> In-Reply-To: <20040312184702.GA16477@Dark-Age.local> from "Eugene Lee" at Mar 12, 2004 12:47:02 PM
next in thread | previous in thread | raw e-mail | index | archive | help
> > My FreeBSD-4.9 setup uses one drive in "dangerously dedicated partition" > where all of my partitions live in one slice: That isn't what "dangerously dedicated" means. It appears you have a standard setup with just one slice of 4 used. A dangerously disk would have partitions of /dev/da0a, /dev/da0e, etc. > $ df > Filesystem 1K-blocks Used Avail Capacity Mounted on > /dev/da0s1a 64462 37886 21420 64% / > /dev/da0s1e 64462 4 59302 0% /tmp > /dev/da0s1f 516062 6086 468692 1% /var > /dev/da0s1g 2064302 1464672 434486 77% /usr > /dev/da0s1h 10660096 720 9806570 0% /data > procfs 4 4 0 100% /proc > > I almost run out of space during a buildworld, so I'd like to expand > /usr from 2 GB to 4 GB by taking space away from /data. Since my > filesystems will remain in the same slice, is it correct that I don't > need to use fdisk(8)? That would be correct. But, you will need to use disklabel and newfs. > So my procedure to do this is to recalculate the size/offset/cylinder > settings for my partitions "g" & "h", change those settings via > disklabel(8), then use growfs(8) on /dev/da0s1g? Seems simple enough, > and the data on /usr should be preserved, correct? Yes and no. I do not think you can shrink a partition with these. Since, in order to grow /dev/da0s1g you will have to shrink /dev/da0s1h I think you cannot do what you want. I may well be wrong on this. I haven't tried it. If you really really must change those partition sizes, I would recommend backing them up with dump. Then using disklabel to make new sized partitions and newfs to make new file systems and then restore the two file systems. My best recommendation, though, is to just move some of the big stuff from /usr such as /usr/ports, /usr/local and /usr/src in to /data and make symlinks. Probably tar is adequate for this. cd /usr tar cvpf /data/ports.tar ports tar cvpf /data/local.tar local tar cvpf /data/src.tar src cd /data tar xvpf ports.tar mv ports usr.ports // my naming convention tar xvpf local.tar mv local usr.local tar xvpf src.tar mv src usr.src cd /usr mv ports ports.old ln -s /data/usr.ports ports mv local local.old ln -s /data/usr.local local mv src src.old ln -s /data/usr.src src Now check things out to make sure it looks good by cd-ing to stuff like cd /usr/ports/www or whatever and look to see that you got to the right place (/data/usr.ports/www) and when you are convinced, go back and clean up cd /usr rm -rf ports.old // Watch for accurate typing here rm -rf local.old // Also, if any files have flags set, you will rm -rm src.old // have unset then with chflags(1) as in cd /data // chflags noschg file_name rm ports.tar // in order to be able to rm them. rm local.tar rm src.tar This should give you back quite a lot of your /usr file system Although ports, local and src are the usual hogs, you may need to use du in the /usr directory to find out what else is taking lots of space if these aren't the ones. Do you have a bunch of home directories there or are you making them in /data for example. > But will /dev/da0s1h be okay? Is editing the disklabel enough? Or do I > need to reformat the partition --- and, if so, how? I'm not too comfy > using newfs(8) directly. Can I just run "newfs /dev/da0s1h" after > running the growfs(8) command and it will use the disklabel settings? > Or can I be a wuss and use /stand/sysinstall? :-) Editing the disklabel will change the partition sizes. Definitely /dev/da0s1h will be messed up. Running newfs on it will build a new filesystem in whatever is now that partition. > > Any suggestions are appreciated, thanks in advance! My above suggestion about moving some dirs is the biggie. ////jerry
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403121922.i2CJMLa19763>