Linu下挂载新硬盘的方法.docx
Linux下挂载硬盘的方法装虚拟机时空间划小了,于是又加/ 5G的空间,折腾了半天,挂上去了。整理下弄个笔记,备用。1 .添加磁盘,查看磁盘状况rootdbl /# fdisk -11305 cylinders1305 cylinders512 = 8225280 bytes255 heads, 63 sectors/track,Units = cylinders of 16065 *Device BootStartEndBlocksIdSystem/dev/sdal *15113059277537+83Linux/dev/sda2150120-1843+82Linux swapPartition table entries are notin diskorderDisk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylindersbytesbytesUnits = cylinders of 16065 * 512 = 8225280Device BootDevice BootStartEndBlocksIdSystem从查询结果看出,多了一个/dev/sdb的盘2 .用fdisk对/dev/sdb进展分区rootdbl /# fdisk /dev/sdbCommand (m for help): nCommand actione extendedp primary partition (1-4)PPartition number (14): 1First cylinder (1-652, default 1):Using default value 1Last cylinder or +sizc or +sizcM or +sizeK (1-652, default 652):Using default value 652Command (m for help):The partition table has been altered!Calling ioctl to re-read partition table. Syncing disks.再次查看分区状况,多山来一个/dev/sdbl的区,这个1是我们在前面指定的,假设我们指 定2,就变成sdb2 了。rootdbl /# fdisk -1255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice BootStartEndBlocksIdSystem/dev/sdal *15113059277537+83Linux/dev/sda211501204843+82Linux swapPartition tableentries are notin diskorderDisk /dcv/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytesrootdbl /#假设创立完之后,/proc/p。什itions查看不到对应的分区,使用parprobe命令刷一下就可以了: rootwebl cat /proc/partitionsmajor minor #blocks name80 175825944 sda811020236 sdal82 30716280 sda28 38193150 sda3root(a)web1 # partprobe /dev/sdaroot(g)web1 # cat /proc/partitions major minor #blocks name80175825944 sda811020236 sda18230716280sda2838193150 sda384135893835sda4rootweb1 #3 .格式化/dev/sdbl分区rootdbl /# mkfs -t ext3 /dev/sdblmke2fs 1.35 (28-Feb-2023)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)655360 inodes, 1309289 blocks65464 blocks (5.00%) reserved for the super userFirst data block=032768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736Writing inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tuno2fs -c or -i to override.4 .创立名目并将/dev/sdbl挂在到该名目下rootdbl /#Isbackup devinitrdmediaoptsbinsysusrbinetclibmiscprocselinuxtftpbootvarboot homelost+foundmntrootsrvtmprootdbl /#mkdir /uOlrootdbl /#Isbackup devinitrdmediaoptsbinsysuOlbinetclibmiscprocseiinuxtftpbootusrboot homelost+foundmntrootsrvtmpvarrootdbl /#mount /dev/sdbl /uOl5 .验证挂载是否成功rootdbl /# df -kFilesystemIK-blocksUsed Available Use% Mounted on/dev/sdal913177270668841601012 82% /none45425604542560% /dev/shm1/dev/ sdbl51548524304048499561% /backup.设置开机自动挂载rootdbl /# vi /ctc/fstab“man fstab-syncM for detailsLABEL=/cxt3defaults1 1none/dev/ptsdevptsgid=5, mode=6200 0none/dev/shmtmpfsdefaults0 0none/procprocdefaults0 0none/syssysfsdefaulIs0 0LABEL=SWAP-sda2swapswapdefaults0 0# This file is edited by fstab-sync - see/dev/sdbl/uOlext3 defaults0 0/dev/hdc/mcdia/cdromautopamconsole, exec, noaulo, managed 0 0/dev/fdO/media/floppyautopaniconsole, exec, noauto, m anaged 0 0