yycvip 发表于 2024-4-30 22:18:12

linux 挂载磁盘命令

把一个磁盘/dev/sda挂载到某个目录下
mkdir /mnt/long //创建一个空的挂载节点
mount -t ext4 /dev/sda /mnt/long查看磁盘分区情况 fdisk -l


查看磁盘挂载情况df


对磁盘/dev/sdb分区
# 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      #设定可启动标记
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition          #删除一个分区
   l   list known partition types#各分区类型所对应的ID
   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): p //打印分区信息,可以看到当前并没有分区

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   IdSystem

Command (m for help): n **//创建一个新的分区**
Command action
   e   extended//输入e为创建扩展分区
   p   primary partition (1-4) //输入p为创建逻辑分区
p
Partition number (1-4): 1**//划分逻辑分区**
First cylinder (1-2610, default 1): **//我这里直接回车,是不想把该磁盘分成多个分**区,把整个磁盘作为1个分区
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 //再次查看可以看到该磁盘已经有1个分区了

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   IdSystem
/dev/sdc1               1      2610    20964793+83Linux
Command (m for help): w //保存分区
The partition table has been altered!

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

格式化磁盘
mkfs.ext3 /dev/sdc1
或者mkfs.xfs修个配置文件开机自动挂载 vim /etc/fstab
vim /etc/fstab
/dev/sdc1(磁盘分区) /disk/disktwo(挂载目录) ext3(文件格式)defaults 0 0


yycvip 发表于 2024-5-17 21:10:42

1、mkdir /www //创建一个空的挂载节点
2、fdisk -l 查询磁盘
fdisk /dev/sda4、用D命令删除
5、建立分区按N
6、格式化:
mkfs.xfs /dev/sda7、挂载:
mount /dev/sda /wwwwvim /etc/fstab9、在文件里保存以下内容
/dev/sda /www xfs defaults 0 1保存重启完事

页: [1]
查看完整版本: linux 挂载磁盘命令