Change the disk partition size in Linux

Source: Internet
Author: User
I didn't have a strong basic knowledge when I first started installing Ubuntu, but I did it according to the online tutorials. I didn't quite understand the principles. When I finished studying the disk partition today, I felt that the space allocated to/home was a little large when I installed ubuntu, 53 GB. I wanted to spare some space, so I began to struggle. My steps are as follows: start the computer and log on to the interface as the root user. If you log on as a normal user, you cannot unmount your/home partition and the busy message is always prompted! Therefore, log on to xwindo directly as the root user.

I didn't have a strong basic knowledge when I first started installing Ubuntu, but I did it according to the online tutorials. I didn't quite understand the principles. When I finished studying the disk partition today, I felt that the space allocated to/home was a little large when I installed ubuntu, 53 GB. I wanted to spare some space, so I began to struggle.

My steps are as follows: start the computer and log on to the interface as the root user. If you log on as a normal user, you cannot unmount your/home partition and the busy message is always prompted! Therefore, log on to xwindow as the root user!

To split the size of the original partition, you must back up the partition first. Otherwise, all data will be lost when the partition is split! Taking my binbin user as an example, I want to reclaim 53 GB and allocate it to binbinbin15 GB. I chose/tmp as the temporary directory. Make sure that the directory size can put down your backup.

Go to/tmp and execute tar-zcpv-f binbin.tar.gz/home/binbin. If you do not understand these options, do it first. After completing this step, we will package all the data of the binbin.tar.gz user and compress it into binbin.tar.gz! Note: If you have video files in your directory, the compression may be slow. Therefore, you can copy these videos to other places, such as USB disks and hard disks. Our main goal is to narrow down the partition!

Then, to unmount the partition under/home, first write down the device name mounted under/home in the df terminal. My name is/dev/sda12. Execute Command
Unmount umount/home or umount/dev/sda12j. Note: You must detach a partition before you can perform operations on it.

After the uninstallation is completed, the partition stage is started. The command fdisk/dev/sda appears:
Root @ ubuntu :~ # Fdisk/dev/sda

WARNING: DOS-compatible mode is deprecated. It's stronugly recommended
Switch off the mode (command 'C') and change display units
Sectors (command 'U ').


Command (m for help ):

If you want to partition the disk, it is relatively simple. Input p to check the current partition table,
Command (m for help): p

Disk/dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x52354190


Device Boot Start End Blocks Id System
/Dev/sda1*1 26 204800 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/Dev/sda2 26 6400 51200000 7 HPFS/NTFS
/Dev/sda3 6400 36988 245692417 f W95 Ext 'd (LBA)
/Dev/sda4 36988 38914 15471960 12 Compaq diagnostics
/Dev/sda5 6400 13057 53468465 7 HPFS/NTFS
/Dev/sda6 16844 27287 83886080 7 HPFS/NTFS
/Dev/sda7 27287 30250 23799663 7 HPFS/NTFS
/Dev/sda8 13057 13306 1998848 82 Linux swap/Solaris
/Dev/sda9 13306 15129 14647296 83 Linux
/Dev/sda10 15130 15154 194560 83 Linux
/Dev/sda11 15154 15278 999424 82 Linux swap/Solaris
/Dev/sda12 30250 32208 15730009 + 83 Linux

Partition table entries are not in disk order

My/dev/sda12 has been reduced, so it is 15 GB ~ It turns out to be GB! Enter d, delete the partition, and select 12
Command (m for help): d
Partition number (1-12): 12

It is time to create a new partition after deletion. This time it will be a little bit smaller ~ Enter n, select the start track number, and end the track number. In fact, enter + 15 GB. Follow the prompts! After creating the partition, use w to save and exit!

At this time, you will be prompted to require reboot to read the disk partition table. If we do not reboot, enter the partprobe command!

After the partition is created, it cannot be mounted directly. You must format it first. Enter The mkfs-t ext3/dev/sda12 command.

Now you can mount: mount/dev/sda12/home.

After mounting, you can go to the/home directory to check whether there is anything, because there is nothing in the just-divided zone. The following is to take the backup file, cd to/tmp, and execute tar-zxvf bin.tar.gz-C/home.

Now, the task of narrowing down the partition is complete!

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.