最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux下如何掛載磁盤的方法示例

 更新時間:2019年09月13日 09:55:26   作者:三國魏  
這篇文章主要介紹了Linux下如何掛載磁盤的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

使用虛擬機時發(fā)現(xiàn)磁盤空間不夠了,需要掛載一個磁盤以供繼續(xù)使用,但是磁盤不是添加就可以使用的,還需要進行掛載。

一、添加磁盤

添加加新硬盤重啟服務(wù)器

添加完之后就可以重啟機器了,如果你機器是開啟的,進入系統(tǒng)并不能看見你剛添加的那塊磁盤,只有等系統(tǒng)重啟,重新加載之后才會顯示安裝的那塊磁盤

二、進入系統(tǒng)

使用root用戶進入系統(tǒng)

三、 查看硬盤信息

[root@localhost ~]# fdisk -l  //磁盤命令
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4cb5

  Device Boot   Start     End   Blocks  Id System
/dev/sda1  *      1     64   512000  83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2       64    2611  20458496  8e Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd0f5c869

  Device Boot   Start     End   Blocks  Id System
/dev/sdb1        1    2610  20964793+ 83 Linux

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

可以看到這臺機器加載了三個磁盤sda、sdb、sdc

其中sda是初始磁盤,sdb已經(jīng)初始化且經(jīng)過使用,sdc是剛剛加載的,未格式化的新磁盤

四、創(chuàng)建新硬盤分區(qū)

[root@localhost ~]# fdisk /dev/sdc #進入磁盤
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x45a3cadb.
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: 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   #設(shè)定可啟動標記
  b  edit bsd disklabel
  c  toggle the dos compatibility flag
  d  delete a partition     #刪除一個分區(qū)
  l  list known partition types #各分區(qū)類型所對應(yīng)的ID
  m  print this menu       #菜單
  n  add a new partition     #添加一個分區(qū)
  o  create a new empty DOS partition table
  p  print the partition table  #顯示該磁盤下的當前分區(qū)信息
  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)

知道命令之后就可以進行分區(qū)了

Command (m for help): p //打印分區(qū)信息,可以看到當前并沒有分區(qū)

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3cadb

  Device Boot   Start     End   Blocks  Id System

Command (m for help): n //創(chuàng)建一個新的分區(qū)
Command action
  e  extended//輸入e為創(chuàng)建擴展分區(qū) 
  p  primary partition (1-4) //輸入p為創(chuàng)建邏輯分區(qū) 
p
Partition number (1-4): 1//劃分邏輯分區(qū)
First cylinder (1-2610, default 1): //我這里直接回車,是不想把該磁盤分成多個分區(qū),把整個磁盤作為1個分區(qū)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): 
Using default value 2610

Command (m for help): p //再次查看可以看到該磁盤已經(jīng)有1個分區(qū)了

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3cadb

  Device Boot   Start     End   Blocks  Id System
/dev/sdc1        1    2610  20964793+ 83 Linux
Command (m for help): w //保存分區(qū)
The partition table has been altered!

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

再次使用”fdisk -l”命令查看磁盤信息

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x406a4c58

  Device Boot   Start     End   Blocks  Id System
/dev/sdc1        1    2610  20964793+ 83 Linux

第三塊磁盤/dev/sdc已經(jīng)分區(qū)好了

五、格式化分區(qū)

[root@localhost ~]# mkfs.ext3 /dev/sdc1
//將/dev/sdc1格式化為ext3類型,好像大部分的磁盤都是格式化為ext3類型,具體為什么沒有深入研究,暫時不清楚,想了解的朋友可以自己查一下
[root@localhost ~]# mkfs.ext3 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
文件系統(tǒng)標簽=
操作系統(tǒng):Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
第一個數(shù)據(jù)塊=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
  4096000

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

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

格式化完畢,此時就可以使用“mount”命令掛載分區(qū)了,然后使用這個磁盤空間了

六、掛載分區(qū)以及開機自動掛載

[root@localhost ~]# df -h //此時只有sda1和sdb1兩個磁盤掛載
Filesystem          Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root  18G  15G 1.5G 92% /
tmpfs             932M  76K 932M  1% /dev/shm
/dev/sda1           485M  40M 421M  9% /boot
/dev/sdb1           20G 1.2G  18G  7% /disk/diskone
/dev/sr0           4.2G 4.2G   0 100% /media/CentOS_6.5_Final
[root@localhost /]# cd /disk/
[root@localhost disk]# ll
總用量 4
drwxr-xr-x. 4 root root 4096 7月 28 17:04 diskone
[root@localhost disk]# cd diskone/
[root@localhost diskone]# ll
總用量 20
drwx------. 2 root root 16384 7月 28 16:12 lost+found
drwxr-xr-x. 2 root root 4096 7月 28 17:09 software
[root@localhost diskone]# cd ../
[root@localhost disk]# mkdir disktwo //創(chuàng)建被掛載的路徑
[root@localhost disk]# ll
總用量 8
drwxr-xr-x. 4 root root 4096 7月 28 17:04 diskone
drwxr-xr-x. 2 root root 4096 8月  1 16:48 disktwo
[root@localhost disk]# mount /dev/sdc1 /disk/disktwo/ //進行掛載
[root@localhost disk]# df -h //再次查看,發(fā)現(xiàn)sdc1已經(jīng)掛載在/disk/disktwo路徑下
Filesystem          Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root  18G  15G 1.5G 92% /
tmpfs             932M  76K 932M  1% /dev/shm
/dev/sda1           485M  40M 421M  9% /boot
/dev/sdb1           20G 1.2G  18G  7% /disk/diskone
/dev/sr0           4.2G 4.2G   0 100% /media/CentOS_6.5_Final
/dev/sdc1           20G 173M  19G  1% /disk/disktwo

磁盤已經(jīng)掛載上了

下面設(shè)置開機自動掛載

編輯/etc/fstab文件,再最后面添加
/dev/sdc1(磁盤分區(qū)) /disk/disktwo(掛載目錄) ext3(文件格式)defaults 0 0

vim /etc/fstab
/dev/sdc1(磁盤分區(qū)) /disk/disktwo(掛載目錄) ext3(文件格式)defaults 0 0

之后重啟就OK啦?。?!

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • v2rayN的延遲是-1的問題解決方法

    v2rayN的延遲是-1的問題解決方法

    這篇文章主要為大家詳細介紹了v2rayN的延遲是-1的問題解決方法,本文通過了相關(guān)示例圖片進行了詳細的講解,需要的小伙伴可以跟隨小編一起學習一下
    2023-08-08
  • Linux進程間通信--使用信號

    Linux進程間通信--使用信號

    本篇文章主要介紹了Linux進程間通信--使用信號的相關(guān)知識。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-04-04
  • Django上線部署之Apache的方法

    Django上線部署之Apache的方法

    這篇文章主要介紹了Django上線部署之Apache的相關(guān)知識,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-08-08
  • 利用iptables來配置linux禁止所有端口登陸和開放指定端口的方法

    利用iptables來配置linux禁止所有端口登陸和開放指定端口的方法

    下面小編就為大家?guī)硪黄胕ptables來配置linux禁止所有端口登陸和開放指定端口的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • C語言中 malloc,calloc,realloc的區(qū)別

    C語言中 malloc,calloc,realloc的區(qū)別

    這篇文章主要介紹了C語言中 malloc、calloc、realloc的區(qū)別的相關(guān)資料,需要的朋友可以參考下
    2017-02-02
  • telnet?nc命令返回“連接失敗”問題及解決

    telnet?nc命令返回“連接失敗”問題及解決

    當使用nc或telnet命令測試端口連接時,如果返回“connection?refused”錯誤,通常可能是因為:1.?目標端口未被監(jiān)聽,即沒有服務(wù)在運行于該端口;2.?防火墻策略阻止了該端口的連接;3.?目標主機配置了只允許特定IP或子網(wǎng)的連接,這些情況都會導(dǎo)致連接嘗試失敗
    2024-10-10
  • Linux包管理工具yum、apt的區(qū)別

    Linux包管理工具yum、apt的區(qū)別

    Linux系統(tǒng)基本分兩大類:RedHat系列:Redhat、Centos、Fedora等;Debian系列:Debian、Ubuntu?等。yum是一個在?Fedora?和?RedHat?以及?SUSE?中的?Shell?前端軟件包管理器。apt是一個在?Debian?和Ubuntu中的Shell前端軟件包管理器。
    2023-04-04
  • 80端口被system占用導(dǎo)致Apache無法啟動的解決方法

    80端口被system占用導(dǎo)致Apache無法啟動的解決方法

    本文給大家介紹80端口被system占用導(dǎo)致Apache無法啟動的解決方法,非常不錯,一起看看吧
    2016-12-12
  • 解決SSH連接超時的2個配置方法

    解決SSH連接超時的2個配置方法

    用SSH客戶端連接linux服務(wù)器時,經(jīng)常會出現(xiàn)與服務(wù)器會話連接中斷現(xiàn)象,照成這個問題的原因便是SSH服務(wù)有自己獨特的會話連接機制。
    2014-04-04
  • linux VPS之間網(wǎng)站數(shù)據(jù)的備份與恢復(fù)(網(wǎng)站遷移教程)

    linux VPS之間網(wǎng)站數(shù)據(jù)的備份與恢復(fù)(網(wǎng)站遷移教程)

    有時候我們需要網(wǎng)站遷移或者網(wǎng)站數(shù)據(jù)需要備份或恢復(fù),那么就需要一些操作了,linux下操作都是命令下執(zhí)行的,特分享下,方便需要的朋友
    2014-02-02

最新評論

肥东县| 台江县| 五大连池市| 石渠县| 长垣县| 同德县| 安福县| 白城市| 东莞市| 东辽县| 灌云县| 盐亭县| 施秉县| 剑阁县| 灵山县| 高碑店市| 鹤岗市| 集安市| 崇信县| 白玉县| 三亚市| 潍坊市| 平南县| 无为县| 长宁区| 易门县| 岳池县| 于都县| 务川| 公安县| 芮城县| 酒泉市| 沈阳市| 扎囊县| 洱源县| 松阳县| 萨迦县| 北川| 临清市| 梓潼县| 玛多县|