linux添加新硬盘、格式化以及自动挂载
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 [root@hdd4~] #fdisk/dev/vdb anaconda-ks.cfg.bash_profile.pki/ .bash_history.bashrc.tcshrc .bash_logout.cshrc.viminfo [root@hdd4~] #fdisk/dev/vdb#下面操作把硬盘所有容量设置为一个分区 Welcometo fdisk (util-linux2.23.2). Changeswillremain in memoryonly, until youdecidetowritethem. Becarefulbeforeusingthewrite command . Devicedoesnotcontainarecognizedpartitiontable BuildinganewDOSdisklabelwithdiskidentifier0xc19c6a55. Command(m for help):n Partition type : pprimary(0primary,0extended,4 free ) eextended Select(defaultp):p Partitionnumber(1-4,default1): Firstsector(2048-629145599,default2048): Usingdefaultvalue2048 Lastsector,+sectorsor+size{K,M,G}(2048-629145599,default629145599): Usingdefaultvalue629145599 Partition1of type Linuxandofsize300GiBis set Command(m for help):w Thepartitiontablehasbeenaltered! Callingioctl()tore- read partitiontable. Syncingdisks. [root@hdd4~] #mkfs-text4/dev/vdb1#格式化/vdb1分区 mke2fs1.42.9(28-Dec-2013) Filesystemlabel= OS type :Linux Blocksize=4096(log=2) Fragmentsize=4096(log=2) Stride=0blocks,Stripewidth=0blocks 19660800inodes,78642944blocks 3932147blocks(5.00%)reserved for thesuperuser Firstdatablock=0 Maximumfilesystemblocks=2227175424 2400block groups 32768blockspergroup,32768fragmentspergroup 8192inodespergroup Superblockbackupsstoredonblocks: 32768,98304,163840,229376,294912,819200,884736,1605632,2654208, 4096000,7962624,11239424,20480000,23887872,71663616 Allocatinggrouptables: done Writinginodetables: done Creatingjournal(32768blocks): done Writingsuperblocksandfilesystemaccountinginformation: done [root@hdd4~] #mkdir/data [root@hdd4~] #mount/dev/vdb1/data [root@hdd4~] #chown-R/data chown :missingoperandafter‘ /data ’ Try 'chown--help' for more information. [root@hdd4~] #chown-Rhadoop:hadoop/data [root@hdd4~] # [root@hdd4~] # [root@hdd4~] #blkid/dev/ Displayall152possibilities?(yorn) [root@hdd4~] #blkid/dev/vdb1 /dev/vdb1 :UUID= "b112cf72-a0a4-45cc-88be-afdc24a1e635" TYPE= "ext4" [root@hdd4~] #cat/etc/fstab # #/etc/fstab #CreatedbyanacondaonTueDec2014:35:532016 # #Accessiblefilesystems,byreference,aremaintainedunder'/dev/disk' #Seemanpagesfstab(5),findfs(8),mount(8)and/orblkid(8)formoreinfo # /dev/mapper/centos-root /xfsdefaults00 UUID=82b43f00-0de4-4571-b093-654128268c31 /boot xfsdefaults00 /dev/mapper/centos-swap swapswapdefaults00 UUID=b112cf72-a0a4-45cc-88be-afdc24a1e635 "TYPE=" ext4 /data ext4defaults00 [root@hdd4~] # [root@hdd4~] #df-h FilesystemSizeUsedAvailUse%Mountedon /dev/mapper/centos-root 18G3.2G15G18%/ devtmpfs16G016G0% /dev tmpfs16G016G0% /dev/shm tmpfs16G89M16G1% /run tmpfs16G016G0% /sys/fs/cgroup /dev/vda1 497M108M390M22% /boot tmpfs3.2G03.2G0% /run/user/1000 tmpfs3.2G03.2G0% /run/user/0 /dev/vdb1 296G65M281G1% /data 本文转自 yanconggod 51CTO博客,原文链接:http://blog.51cto.com/yanconggod/1892266