centos 格式化硬盘并挂载,添加重启后生效

[[email protected] /]# passwd
更改用户 root 的密码 。
新的 密码:
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[[email protected] /]# fdisk

Usage:
 fdisk [options] <disk>    change partition table
 fdisk [options] -l <disk> list partition table(s)
 fdisk -s <partition>      give partition size(s) in blocks

Options:
 -b <size>                 sector size (512, 1024, 2048 or 4096)
 -c                        switch off DOS-compatible mode
 -h                        print help
 -u <size>                 give sizes in sectors instead of cylinders
 -v                        print version
 -C <number>               specify the number of cylinders
 -H <number>               specify the number of heads
 -S <number>               specify the number of sectors per track

[[email protected] /]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x00073ffb

   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        1306     9972736   8e  Linux LVM

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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

Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes
255 heads, 63 sectors/track, 984 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

Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 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

[[email protected] /]# df -h
文件系统              容量  已用  可用 已用%% 挂载点
/dev/mapper/vg_cloud-lv_root
                      7.5G  3.5G  3.7G  49% /
tmpfs                 503M   72K  503M   1% /dev/shm
/dev/sda1             485M   32M  428M   7% /boot
[[email protected] /]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6f476ca3.
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
   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): n
Command action
   e   extended
   p   primary partition (1-4)
1
Invalid partition number for type `1‘
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, +cylinders or +size{K,M,G} (1-6527, default 6527):
Using default value 6527

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

Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] /]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x00073ffb

   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        1306     9972736   8e  Linux LVM

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x6f476ca3

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

Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes
255 heads, 63 sectors/track, 984 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

Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 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

[[email protected] /]# mkfs.ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=0
400 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, 7962624, 11239424

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

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[[email protected] /]# ls
bin   dev  home  lost+found  media2  mnt  opt   root  selinux  sys  usr
boot  etc  lib   media       misc    net  proc  sbin  srv      tmp  var
[[email protected] /]# cd home
[[email protected] home]# ls
[[email protected] home]# ls -a
.  ..
[[email protected] home]# cd ..
[[email protected] /]# mount /dev/sdb1 /home/
[[email protected] /]# df -h
文件系统              容量  已用  可用 已用%% 挂载点
/dev/mapper/vg_cloud-lv_root
                      7.5G  3.4G  3.7G  48% /
tmpfs                 503M   72K  503M   1% /dev/shm
/dev/sda1             485M   32M  428M   7% /boot
/dev/sdb1              50G  180M   47G   1% /home
[[email protected] /]# echo "/dev/sdb1 /home ext3 defaults 1 1" >> /etc/fstab
[[email protected] /]# reboot

Broadcast message from [email protected]
        (/dev/pts/0) at 21:03 ...

The system is going down for reboot NOW!

首先修改密码:passwd

查看磁盘信息:df -h

磁盘分区:fdisk

格式化硬盘:mkfs

挂载:mount

使挂载重启后生效:echo "/dev/sdb1 /home ext3 defaults 1 1" >> /etc/fstab

时间: 2025-01-27 03:54:18

centos 格式化硬盘并挂载,添加重启后生效的相关文章

在CentOS 6.5里添加一块硬盘,分区并格式化后,挂载到/data下

常用命令: [[email protected] etc]# uname –a------à查看内核版本 Linux goodluck 2.6.32-431.el6.x86_64 #1 SMPFri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [[email protected] etc]# cat /proc/version -----------à查看内核等版本信息 Linux version 2.6.32-431.el6.

kvm热添加磁盘,并为根目录扩容,重启依然生效

接上篇,<<热添加磁盘,重启文件不丢失>> 一.理论扫盲:centos7的磁盘默认使用lvm,所以是可以直接扩展根分区的,但是无法缩小,在物理机中会默认将磁盘分为两个分区,分别为sda1和sda2,其中分区sda1作为系统盘/boot挂载,少量空间:sda2作为一个物理卷并且完全作为逻辑卷组VG(Volume Group)centos,在这个逻辑卷组centos中建立三个逻辑卷LV(Logical Volume)root和home还有swap,分别挂载到根目录/和/home以及sw

linux添加静态路由表,重启继续生效

在日常的使用中,或者在服务器中,有两个网卡配置两个地址,访问不同的网络段,这种情况是非常常见的现象,但是,我们需要额外的添加路由表来决定发送的数据包经过正确的网关和interface才能正确的进行通信 今天来介绍在linux操作系统中如何添加路由(主要针对rhel系列,测试平台为rhel5.4) 一.使用route命令添加临时路由 添加到主机的路由 # route add -host 192.168.1.123 dev eth0 # route  add -host 192.168.1.123

要想重启后也生效LINUX防火墙配置

新配置的一台服务器,安装的是CentOS6.3系统,在安装完LNMP之后,发现nginx进程存在,且php解析正常,但是用分配的独立IP去访问的时候发现无法访问. 查了下网上的资料,发现可能是Linux防火墙iptables导致nginx不能访问.我们访问一个网站,一般用的是80端口,那么这个问题的原因可能就是80端口的访问被拦截了.查看/etc/sysconfig/iptables文件,发现里面没有80端口的配置规则,需要修改下iptables. 在root权限下执行: iptables -A

SMB服务器重启后自动挂载失效

上周五公司停电,这周回来上班后发现公司SMB服务器无法访问,SSH到服务器,df一下,发现挂载记录丢失,如下图,正常情况下应该有一条/dev/sdb1挂载在mnt的记录. 既然挂载丢失,手动挂载一下下,mount /dev/sdb1 /mnt可恢复访问,但服务器重启后现象依旧,难道自动挂载记录也丢失了,我们来看一下fstab: 发现挂载记录还在,那运行一下mount -a吧,看挂载是否有问题: 果不其然,报错了,看来问题还是出在挂载这一块,仔细检查了下fstab文件,终于找到问题所在了,原来是磁

zbb20181010 springboot工具 修改代码后不需重启即生效 自动生效

<!-- springboot工具 修改代码后不需重启即生效 --> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId>

【CentOS】fstab挂载项错误,无法正常启动系统的解决方法

因/etc/fstab的配置错误,导致重启系统时,无法正常进入系统,会卡在以下的页面. 提示的错误信息类似: An   error   occurred  during   the  file   system   check. 解决方法: 1.在错误的启动界面处输入root的密码(不会有显示的,只管输入正确的密码即可) 2.然后会出现(Repair  filesystem)1#的提示符,在其后面输入运行:mount  -no  remount,rw   / 3.编辑/etc/fstab的文件,

[转] CentOS 7 为firewalld添加开放端口及相关资料

转自http://www.cnblogs.com/hubing/p/6058932.html 1.运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查看状态:# systemctl status firewalld 或者 firewall-cmd --state 停止:# systemctl disable firewalld 禁用:# systemctl stop firewalld 查看firewall是否运行,下面两个命令都可以 syste

NFS使用mount挂载无法挂载出问题后的排错思路(七)

NFS使用mount挂载无法挂载出问题后的排错思路 首先确认NFS服务端配置和服务是OK的, 在服务端使用showmount -e localhost  检查 [[email protected] ~]# showmount -e localhost Export list for localhost: /data/r_shared 192.168.221.1/24 /data/w_shared 192.168.221.1/24 2.确认NFS客户端showmount是否OK [[email p