Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.
Modern IT silently made some common problem go away: "No space left on device" became really rare during these days, but I started getting it last week when running some tests with huge data packages. My Ubuntu partition is 20 GB plus 8 GB swapspace and some more for a crypted data partition, but some 180 GB are still blocked by factory Windows 7 installed on this laptop.
Before you start to do anything: Backup your data! I strongly suggest that you download a Ubuntu live image and prepare a bootable USB stick before working on your partition table.
Also check that /etc/fstab and /boot/grub/grub.cfg (or /etc/lilo.conf) are using "UUID=" for partition identification and not fixed values like "/dev/sda1"!
A nice tool called ntfsresize exists for Linux. I started calling
sudo ntfsresize -i /dev/sda2to check the amount of space available for shrinking. My NTFS partition was using some 77 GB for data and I decided to shrink it to 90 GB:
sudo ntfsresize -ns 90 GB /dev/sda2Checked the partition and told me that shrinking to 90 GB was possible. The same command using "-s" instead of "-ns" shrunk the partition to 90 GB.
Yeah, I'm done!
But... the partition is still using 180 GB, what went wrong? nfsresize is freeing the space, but doesn't resize the partition itself. I don't trust GUI tools as much as good old command line tools, especially when working with real data. The old plain fdisk utility is perfect for working on the partition table:
sudo fdisk /dev/sdaThe "p" command prints out the current table - and my windows partition /dev/sda2 still was at it's original size. I removed it using the "d" command and re-created it using "n" and the original start position and nothing less than the size given to ntfsresize, I copied the old starting sector and used +90GB for the end. Another "p" command printed the new partition size, but the recreation mixed up the type which has to be re-set to "7" using the "t" command. Oh, don't forget to issue a "w" command to flush the partition table.
Yippi, cutting down Windows was successful!
But I'd like to actually use this space for data and re-installing Ubuntu isn't something planned for today. My partition table has the following items now:
- Windows 7 boot partition (1,3 GB)
- Windows 7 partition (90 GB)
- Unused space (some 88 GB)
- Extended partition
- Ubuntu/Linux partition (20 GB)
- Swapspace (8 GB)
- Crypted data partition
- Lenovo Thinkpad Recovery tool
The next step was critical: Extending the extended partition to include the free space in front of the partition. Even if the kernel is using his cached version of the table, I didn't want to do this while running a system from a partition I was going to delete and recreate. After booting a live Ubuntu using the prepared USB stick, I launched fdisk again - and a texteditor.
Again "p" printed the partition table and I copied these important information into the text editor for later reference before I deleted the extended partition using "d". The new extended partition started at the first block of the free space (fdisk suggestion and the last windows partition block number plus 1) and ended at the end of the old extended partition (from the information copied into the texteditor). The three old linux partitions also had to be recreated at the exactly same positions (start and end block) they used before. One block more or less - and all data
might will be lost. Remember to check and set the correct type numbers to their previous values.
Last step: Create a new partition covering the free space at the beginning of the new extended partition for later usage within Ubuntu and flushing the changes using "w".
Everything went fine while rebooting from hard disk - and my new data partition was ready for being formatted and used.
1 Kommentar. Schreib was dazu
Danke schön, gute Hinweise!