Add new partition in Ubuntu

Source: Internet
Author: User

Recently I am working on an android project, but after extracting the root file system, I reported that the hard disk is not enough. The configured size is 15 GB. However, it is very convenient to expand partitions. Of course, first you have to set the size of the hard disk to be added. This time, I upgraded it to 30 GB to see if it has an alarm.

1. Create a New Partition
First, check the existing partitions:
Root @ Ubuntu :/#Fdisk-l

Disk/dev/SDA: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x000e11ac

Device boot start end blocks ID system
/Dev/sda1*1 1871 15021056 83 Linux
/Dev/sda2 1871 1958 704513 5 extended
/Dev/sda5 1871 1958 704512 82 Linux swap/Solaris
Root @ Ubuntu :/#
From the information above, we can see the two primary partitions/dev/sda1 and/dev/sda2, so we can create/Dev/sda3
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 ):
M for help.MFor help;
Command action
A toggle a bootable flag
B edit BSD disklabel
C toggle the DOS compatibility flag
D delete a partition
L List known partition types
MPrint this menu
NAdd a new partition
O create a new empty DOS partition table
P print the Partition Table
QQuit without saving changes
S create a new empty sun disklabel
T change a partition's System ID
U change display/entry units
V verify the Partition Table
WWrite table to disk and exit
X extra functionality (experts only)

Command (M for help ):
According to the above information,NTo add a partition, that is, to create a partition; W to save.
Command (M for help): n
Command action
L logical (5 or over)
P primary partition (1-4)
Create a logical partition or primary partition. EnterPCreate a primary partition.
If:
Selected partition 4
No free sectors available
Indicates that there is no idle hard disk, and you have to manually add it to the virtual machine.
Then press the default data input, and finally remember to enterWSave.QTo exit.

Ii. format the new partition and set the mount point
Format:
Root @ Ubuntu :/#Mkfs. ext4/dev/sda3
Create a mount point:
Root @ Ubuntu :/#Mount-T ext4/dev/sda3/home/work
Mount the new partition to the/home/work directory. The size of the/home/work directory is the size of the hard disk that you add first.
In this case, you can see that there isLost + foundDirectory.

3. Enable automatic mounting upon system startup

As long/Etc/fstabAdd a row in. You should know that the root file system has been used:

/Dev/sda3/home/work ext4 defaults 1 0

It will take effect after restart.

View usage:
Root @ Ubuntu :/#DF
Filesystem 1k-blocks used available use % mounted on
/Dev/sda1 14784996 5147264 8886680 37%/
None 248640 208 248432 1%/dev
None 254244 248 253996 1%/dev/SHM
None 254244 384 253860 1%/var/run
None 254244 0 254244 0%/var/lock
/Dev/sda3 15480852 8684096 6010376 60%/Home/work
Root @ Ubuntu :/#
Of course, I have added many things in the/home/work directory.

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.