[Linux] [Ubuntu] automatic partitioning

Source: Internet
Author: User
Turn: http://pppboy.blog.163.com/blog/static/3020379620101024105426723/

 1. View partitions

ju@musicoder:~$ sudo fdisk -l 
[sudo] password for ju: 
Disk /dev/sda: 250.1 GB, 250059350016 bytes
240 heads, 63 sectors/track, 32301 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x77777777
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3468    26218048+   7  HPFS/NTFS
/dev/sda2            3469       32300   217969889+   f  W95 Ext'd (LBA)
/dev/sda5            3469       13464    75569728+   7  HPFS/NTFS
/dev/sda6           13465       20399    52428568+   7  HPFS/NTFS
/dev/sda7           20400       27334    52428568+   7  HPFS/NTFS
/dev/sda8           27335       27473     1050808+  82  Linux swap / Solaris
/dev/sda9           27474       27500      204088+  83  Linux
/dev/sda10          27501       30968    26218048+  83  Linux
/dev/sda11          30969       32300    10069888+  83  Linux

As you can see, I divided the hard disk into four Linux partitions and four NTFS partitions.

Ii. View UUID

ju@musicoder:~$ sudo blkid 
/dev/sda1: LABEL="win" UUID="6E105E80105E4F69" TYPE="ntfs" 
/dev/sda5: LABEL="soft" UUID="64F47CE6F47CBC3C" TYPE="ntfs" 
/dev/sda6: LABEL="work" UUID="3C20C09B20C05E10" TYPE="ntfs" 
/dev/sda7: LABEL="document" UUID="DA68CADA68CAB493" TYPE="ntfs" 
/dev/sda8: UUID="282e669c-beec-4768-b75d-39ae089fbca2" TYPE="swap" 
/dev/sda9: UUID="54430890-54bb-4426-aa0c-f4d474eb50c4" TYPE="ext3" 
/dev/sda10: UUID="af6a6d5d-c16b-4b8d-a29d-2aa6f12b6de2" TYPE="ext3" 
/dev/sda11: UUID="70abe683-c21d-48f0-90fa-d0ee72c03b51" TYPE="ext3" 
ju@musicoder:~$ 

 

3. Create a mount directory

ju@musicoder:~$ sudo mkdir /mnt/d /mnt/e /mnt/f
ju@musicoder:~$ ls /mnt/
d  e  f
ju@musicoder:~$ 

 

4. Edit the/etc/fstab file (do not forget to back up the file)

ju@musicoder:~$ cd /etc/
ju@musicoder:/etc$ sudo cp fstab fstab_back_101118
ju@musicoder:/etc$ sudo gedit fstab

 

5. This is the opened fstab file.

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda10 during installation
UUID=af6a6d5d-c16b-4b8d-a29d-2aa6f12b6de2 /               ext3    errors=remount-ro 0       1
# /boot was on /dev/sda9 during installation
UUID=54430890-54bb-4426-aa0c-f4d474eb50c4 /boot           ext3    defaults        0       2
# /home was on /dev/sda11 during installation
UUID=70abe683-c21d-48f0-90fa-d0ee72c03b51 /home           ext3    defaults        0       2
# swap was on /dev/sda8 during installation
UUID=282e669c-beec-4768-b75d-39ae089fbca2 none            swap    sw              0       0

Add the following content for automatic mounting.

UUID=64F47CE6F47CBC3C  /mnt/d  ntfs  defaults,codepage=936,iocharset=gb2312 0 0
UUID=3C20C09B20C05E10  /mnt/e  ntfs  defaults,codepage=936,iocharset=gb2312 0 0
UUID=DA68CADA68CAB493  /mnt/f  ntfs  defaults,codepage=936,iocharset=gb2312 0 0 

Of course, some people can add the following methods.

/dev/sda5 /mnt/d ntfs user,nls=utf8,umask=0222,gid=1000,auto 0
/dev/sda6 /mnt/e  ntfs user,nls=utf8,umask=0222,gid=1000,auto 0
/dev/sda7 /mnt/f ntfs user,nls=utf8,umask=0222,gid=1000,auto 0

 

6. After restarting, enter/mnt/and you will find the mounted partition.

ju@musicoder:/etc$ sudo shutdown -r now

 

7. If you want to put the partition on the desktop, just link it.

ju@musicoder:~$ ln -s /mnt/e /home/ju/desktop/e

The mounted windows partition will be found on the desktop.

 

8. Better methods (for individuals)

Ubuntu (10.04lts) is used by the user. When the partition is mounted to/Media/, a desktop icon is automatically displayed to open the partition. Therefore, it is better to mount the partition to/Media /.

1. Create a mount directory

ju@musicoder:/media$ sudo mkdir d e f
[sudo] password for ju: 
ju@musicoder:/media$ ls
d  e  f
ju@musicoder:/media$ 

2. Edit fstab and change the mounted partition to/Media:

UUID=64F47CE6F47CBC3C  /media/d  ntfs  defaults,codepage=936,iocharset=gb2312 0 0
UUID=3C20C09B20C05E10  /media/e  ntfs  defaults,codepage=936,iocharset=gb2312 0 0
UUID=DA68CADA68CAB493  /media/f  ntfs  defaults,codepage=936,iocharset=gb2312 0 0 

3. You can delete all directories under/mnt/created previously.

 

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.