13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 5 ■ WORKING WITH FILESYSTEMSOK, then, here’s how to actually go about this.Boot from a rescue disk or LiveCD if you will be resizing your / partition at all, as in this example. Ifyou’re just resizing other partitions, then you can boot from / as normal and unmount any otherpartitions after bootup.umount /dev/hda2Use fdisk -l to find the start and end of the partitions:> fdisk -lDevice Boot Start End Blocks Id <strong>System</strong>/dev/hda1 . 1 1288 10345828 83 <strong>Linux</strong>/dev/hda2 1289 8924 61336138 83 <strong>Linux</strong>Using parted, shrink /dev/hda2 to 50GB, leaving 55GB spare at the end. parted takes the size inmegabytes, and fdisk gives the size in 1KB blocks, so you need to translate from the 1KB block size thatfdisk has given you to the megabytes that parted needs. You can use the calculator bc to do this(multiply the number of 1KB blocks by 1,024 to get the total bytes, and then divide by 2^20 to getmegabytes).> echo "10345828*1024/(2^20)" | bc10103> parted resize /dev/hda2 10104 61303■ Note That first bc line gives the megabyte size of the first partition (10103MB); add one to get the start of thenext partition, and then add 50GB (51200MB) to that to get the end.Create a third partition in that 55GB using fdisk and mke2fs:> fdiskfdisk> nfdisk> 3fdisk> 83fdisk> w> mke2fs -j /dev/hda3> mkdir /mnt/newpart> mount -t ext3 /dev/hda3 /mnt/newpartCopy the data from /dev/hda2 to the new partition:> cp -rf /local/* /mnt/newpart125Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!