1. 程式人生 > >硬碟(2T及2T以上)分割槽掛載

硬碟(2T及2T以上)分割槽掛載

1.2T硬碟分割槽方法

[[email protected] ~]# fdisk /dev/sdm
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x286f1369.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: The size of this disk is 4.0 TB (3999999687168 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).


The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
		 
Command (m for help): m   --檢視幫助
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
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit 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
   w   write table to disk and exit
   x   extra functionality (experts only)
   
   Command (m for help): n  --增加分割槽
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1   --設定分割槽ID
First cylinder (1-486305, default 1):    --直接回車,設定開始柱面,預設為1
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):   --直接回車,設定結束柱面,預設為磁碟的最大空間
Using default value 267349

Command (m for help): w   --寫入磁碟並退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

2.大硬碟(2T以上)硬碟分割槽方法

[[email protected] ~]# parted /dev/sdm     --對sdm進行操作
GNU Parted 1.8.1
使用 /dev/sdm
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt               -設定分割槽型別為gpt
警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
parted: invalid token: gpt
是/Yes/否/No? yes                                                         
新的磁碟標籤型別?  [gpt]?       回車                                         
(parted) mkpart                                                           
分割槽名稱?  []?        回車                                                   
檔案系統型別?  [ext2]? ext4                                             
起始點? 0                                                 
結束點? 3T            --大小3TB,按實際要求設定,全盤都劃為一個分割槽寫-1                                          
(parted) quit

3.格式化分割槽

[[email protected] ~] mkfs.ext4 -T largefile /dev/sdm1
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdm1 alignment is offset by 3072 bytes.
This may result in very poor performance, (re)-partitioning suggested.
檔案系統標籤=
OS type: Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3814784 inodes, 976562183 blocks
48828109 blocks (5.00%) reserved for the super user
第一個資料塊=0
Maximum filesystem blocks=4294967296
29803 block groups
32768 blocks per group, 32768 fragments per group
128 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: 完成                            
正在寫入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

4.掛載分割槽

[[email protected] ~]# mkdir /home/data1                --建立掛載點
[[email protected] ~]# mount /dev/sdm1 /home/data1   --掛載sdm1
[[email protected] ~]# tune2fs -m 1 /dev/sdm1     
tune2fs 1.41.12 (17-May-2010)
Setting reserved blocks percentage to 1% (4883780 blocks)
linux的硬碟分割槽程式會自動為root或指定的使用者保留一定的磁碟空間,預設是5%。在較大的分割槽上這種設定會佔據過多不必要的空間,此命令可以將保留的空間設定為1%

5.將分割槽資訊寫入/etc/fstab檔案

1.獲取硬碟分割槽UUID

[[email protected] ~]# blkid /dev/sdm1
/dev/sdm1: UUID="86269080-ad85-4811-9a3c-c77ce8282e2d" TYPE="ext4"
2.在/etc/fstab里加入最後一行,儲存退出
# /etc/fstab
# Created by anaconda on Sat Dec 12 15:44:41 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=e3dfd3df-2cf5-449b-8ed7-0a3a9fde8255 /                       ext3    defaults        1 1
UUID=f0378ca7-e884-480a-aaef-4a34623b18e3 /boot                   ext3    defaults        1 2
UUID=5bbf4384-d4c4-4ec6-9950-57ddebf1fed6 /home                   ext3    defaults        1 2
UUID=5b0a63a0-b8c2-4a0b-bad9-a9b351de0b14 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=86269080-ad85-4811-9a3c-c77ce8282e2d /home/data1 ext4 defaults 0 0

在系統裡建立了一個新的分割槽後,因為mount掛載在重啟後會失效,所以需要將分割槽資訊寫到/etc/fstab檔案中讓其永久掛載