查看linux硬盘挂载到指定目录

本文档详细记录了在Linux系统中如何查看硬盘信息,并将新的硬盘分区挂载到/data目录的过程。首先使用fdisk命令检查磁盘情况,创建新的分区,然后格式化为ext3文件系统,最后创建/data目录并将其永久挂载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@ZJIDCInterface1 ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26        2575    20482875   83  Linux
/dev/sda3            2576        3085     4096575   82  Linux swap / Solaris
/dev/sda4            3086        6527    27647865    5  Extended
/dev/sda5            3086        6527    27647833+  83  Linux

Disk /dev/sdb: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@ZJIDCInterface1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              19G   11G  7.4G  60% /
/dev/sda1             190M   12M  169M   7% /boot
tmpfs                 2.0G  108K  2.0G   1% /dev/shm
/dev/sda5              26G  852M   24G   4% /usr/local/apache-tomcat-6.0.35/logs
[root@ZJIDCInterface1 ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26        2575    20482875   83  Linux
/dev/sda3            2576        3085     4096575   82  Linux swap / Solaris
/dev/sda4            3086        6527    27647865    5  Extended
/dev/sda5            3086        6527    27647833+  83  Linux

Disk /dev/sdb: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@ZJIDCInterface1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6527, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527): 
Using default value 6527

Command (m for help): p

Disk /dev/sdb: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        6527    52428096   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@ZJIDCInterface1 ~]# mkfs.ext
mkfs.ext2  mkfs.ext3  
[root@ZJIDCInterface1 ~]# mkfs.ext3  /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6553600 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@ZJIDCInterface1 ~]# mkdir /data
[root@ZJIDCInterface1 ~]# mount  /dev/sdb1  /data
[root@ZJIDCInterface1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              19G   11G  7.4G  60% /
/dev/sda1             190M   12M  169M   7% /boot
tmpfs                 2.0G  108K  2.0G   1% /dev/shm
/dev/sda5              26G  852M   24G   4% /usr/local/apache-tomcat-6.0.35/logs
/dev/sdb1              50G  180M   47G   1% /data
[root@ZJIDCInterface1 ~]# vim  /etc/fstab 

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/program          /program                ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
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
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/sda5               /usr/local/apache-tomcat-6.0.35/logs  ext3    defaults  1 2
/dev/sdb1               /data                    ext3    defaults    0  0
~                                                                                    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值