create partition Table/partition/format/Auto mount under Ubuntu server

Source: Internet
Author: User

Link:http://www.thxopen.com/linux/2014/03/30/linux_parted.html

The process is: New partition--"formatted partition--" Mount Partition

First understand the definition of partition, I find the description of MBR and GPT partition on the net:

MBR partition (master boot record) Table: Supports maximum volume: 2T (T; TERABYTES,1TB=1024GB) Partitioning: Up to 4 primary partitions or 3 primary partitions plus one extended partition.

GPT partition (GUID partition Table) Table: Supports maximum volumes: 18EB, (E:EXABYTES,1EB=1024TB) supports up to 128 partitions per disk

First: The new partition has Fdisk and parted commands under Linux, because Fdisk does not support GPT, you need to use parted to perform the next operation on the hard disk (PS: Using the fdisk command, there is a warning message:warning:gpt (GUID Partition Table) detected on '/DEV/SDA '! The util Fdisk doesn ' t support GPT. Use GNU Parted.)

Note: All of the following actions have been manipulated and the information displayed is slightly different. Data is priceless, please back up the data before operation.

But first, to view the hard drive identified by the current system through FDISK

?
12345678910111213141516171819202122232425262728 [email protected]:~$ sudo fdisk -l[sudo] password for smotive:Disk /dev/sda: 320.1 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectorsUnits = 扇区 of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk identifier: 0x000109ef   设备 启动      起点          终点     块数   Id  系统/dev/sda1*        2048   617381887   308689920   83  Linux/dev/sda2 617383934   625141759     3878913    5  扩展Partition 2 does not start on physical sector boundary./dev/sda5617383936   625141759     3878912   82  Linux 交换 / SolarisWARNING: GPT (GUID Partition Table) detected on ‘/dev/sdb‘! The util fdisk doesn‘t support GPT. Use GNU Parted.Disk /dev/sdb: 500.1 GB, 500107862016 bytes255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectorsUnits = 扇区 of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xd87cd87c    设备 启动      起点          终点     块数   Id  系统/dev/sdb11   976773167   488386583+  ee  GPT   --这里显示不同,是因为我已经操作过了,对照完成下面的操作即可 ,/dev/sdb1 在下面将会用到

You can see that the system recognizes two hard drives/DEV/SDA &/dev/sdb, and now I'm going to set up the/DEV/SDB partition table, partition and format and let the system mount automatically

?
12345 [email protected]:~$ sudoparted /dev/sdbGNU Parted 2.3使用 /dev/sdb欢迎使用 GNU Parted! 输入 ‘help‘可获得命令列表.(parted)  mklabel gpt

At this point you will be prompted to delete all data, whether to continue, enter Yes here, after the completion of the operation, then enter the Print command to view the hard disk information has been established partition table

?
12345678 (parted) printModel: ATA WDC WD5000AADS-0 (scsi)磁盘 /dev/sdb: 500GBSector size (logical/physical): 512B/512B分区表:gpt数字  开始:  End    大小   文件系统  Name     标志 1    17.4kB  500GB  500GB  ext4      primary     --在实际操作过程这个是暂时不会显示,这里由于我的硬盘已经执行过操作了

Next partition, enter the following command

?
1 mkpart primary 0 -1

This represents the entire hard disk as a partition to use, at the time of execution will prompt you whether to continue, here Select Yes, then warning, the partition after the alignment does not achieve the best performance, ignore or cancel, ignore, and then print the information

?
12345678 (parted) printModel: ATA WDC WD5000AADS-0 (scsi)磁盘 /dev/sdb: 500GBSector size (logical/physical): 512B/512B分区表:gpt数字  开始:  End    大小   文件系统  Name     标志 1    17.4kB  500GB  500GB  ext4      primary   --分区完后这里即显示,但是文件系统还是空白,接下来需要格式化才行

Here, create the partition table, the partition is complete, exit parted

?
12 (parted)quit                                                            Information: You may need to update /etc/fstab. --这里的提示就是下面要说的系统启动自动挂载,需要修改   /etc/fstab这个文件

Now to format the hard disk, a hard disk needs to be formatted, to be used by the system, according to the information listed fdisk-l, I need to format the device name/DEV/SDB1, specific reference to the above information

?
1 mkfs.ext4 /dev/sdb1--把硬盘格式化为ext4的文件系统格式

The next step is done automatically, waiting for the prompt to succeed. Next is to mount the hard drive to the system, Windows will have C D E F disk, and Linux is the name of the folder to distinguish the device, since the system to use this hard disk, then you need to set up a folder to be associated with this hard disk

I create a folder in my home directory

?
1 mkdir/home/smotive/wd500

Then mount the hard drive

?
1 mount/dev/sdb1/home/smotive/wd500

Then view the system Mount information

?
123456789 [email protected]:~$ df -h文件系统        容量  已用  可用 已用% 挂载点/dev/sda1290G  2.3G  273G    1% /udev            1.8G  4.0K  1.8G    1% /devtmpfs           731M  420K  730M    1% /runnone            5.0M     0  5.0M    0% /run/locknone            1.8G     0  1.8G    0% /run/shmcgroup          1.8G     0  1.8G    0% /sys/fs/cgroup/dev/sdb1459G   70M  435G    1% /home/smotive/wd500--此时硬盘已经挂载到系统,可以存放文件使用了

Next, modify the/etc/fstab file to automatically mount the hard disk after the system restarts, open the file

?
123456789101112131415161718192021 # /etc/fstab: static file system information.## Use ‘blkid‘ 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            /procproc    nodev,noexec,nosuid 0       0# / was on /dev/sda1 during installationUUID=6ffe07b3-2c5f-4a82-b3b0-bed73c0efe47 /               ext4    errors=remount-ro 0       1# swap was on /dev/sda5 during installationUUID=9eaf6d20-c2cf-407b-b06b-fc93c486634c none            swap    sw              0       0/dev/sdb1/home/smotive/wd500 ext4    defaults        0       2 #第一列:设备名或者设备卷标名,(/dev/sda10 或者 LABEL=/)#第二列:设备挂载目录        (例如上面的“/”或者“/mnt/D/”)#第三列:设备文件系统       (例如上面的“ext3”或者“vfat”)#第四列:挂载参数     (看帮助man mount)#第五列:指明是否要备份。(0为不备份,1为要备份,一般根分区要备份)#第六列:指明自检顺序。 (0为不自检,1或者2为要自检,如果是根分区要设为1,其他分区只能是2)</pass></dump></options></type></mount></file>

Edit OK and save exit

Modify the/etc/fstab, you should use mount-a will be mounted to test, then mount read/etc/fstab content to mount, if there is no error/etc/fstab entry, then mount-a no display, indicating the success of the Mount; Then follow the prompts to troubleshoot. My first operation due to mount directory error is not able to boot, and then online looking for ways to enter the recovery mode modification, specifically see here Recovery mode modified/etc/fatab file

Finished, the above for my study of bird's private food notes, but also reference the online information, hope to bring you help

Set up partition table/partition/Format/Auto Mount (GO) under Ubuntu server

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.