[root@hadoop1 桌面]# 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 0x78495c97.
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)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@hadoop1 桌面]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sr0
sda
├─sda1 ext4 5f52bb93-54df-48a1-9678-c9ad30f2b1bd /boot
├─sda2 swap a187305b-bf2f-4e8f-87d4-56b88229bbdc [SWAP]
└─sda3 ext4 d6663612-cfa4-46db-b5b5-139e46ba891a /
sdb
└─sdb1
[root@hadoop1 桌面]# mkfs -t ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (8192 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.
[root@hadoop1 桌面]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sr0
sda
├─sda1 ext4 5f52bb93-54df-48a1-9678-c9ad30f2b1bd /boot
├─sda2 swap a187305b-bf2f-4e8f-87d4-56b88229bbdc [SWAP]
└─sda3 ext4 d6663612-cfa4-46db-b5b5-139e46ba891a /
sdb
└─sdb1 ext4 5b1d3c65-ce55-40a5-98d7-43893574bfb3
[root@hadoop1 桌面]# mkdir /home/newdisk
[root@hadoop1 桌面]# cd /home
[root@hadoop1 home]# mount /dev/sdb1 /home/newdisk
[root@hadoop1 home]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sr0
sda
├─sda1 ext4 5f52bb93-54df-48a1-9678-c9ad30f2b1bd /boot
├─sda2 swap a187305b-bf2f-4e8f-87d4-56b88229bbdc [SWAP]
└─sda3 ext4 d6663612-cfa4-46db-b5b5-139e46ba891a /
sdb
└─sdb1 ext4 5b1d3c65-ce55-40a5-98d7-43893574bfb3 /home/newdisk
[root@hadoop1 home]# cd newdisk/
[root@hadoop1 newdisk]# ls
lost+found
[root@hadoop1 newdisk]# vim /etc/fstab
[root@hadoop1 newdisk]# mount -a
[root@hadoop1 newdisk]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18244476 3287156 14023896 19% /
tmpfs 1019184 224 1018960 1% /dev/shm
/dev/sda1 194241 39059 144942 22% /boot
/dev/sdb1 2030736 3072 1922844 1% /home/newdisk
[root@hadoop1 newdisk]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 3.2G 14G 19% /
tmpfs 996M 224K 996M 1% /dev/shm
/dev/sda1 190M 39M 142M 22% /boot
/dev/sdb1 2.0G 3.0M 1.9G 1% /home/newdisk
[root@hadoop1 newdisk]# du -ach --max-depth=1 /opt
164K /opt/home
152K /opt/tmp
53M /opt/VMwareTools-10.3.2-9925305.tar.gz
4.0K /opt/rh
160M /opt/vmware-tools-distrib
213M /opt
213M 总用量
[root@hadoop1 newdisk]# ls -l /home |grep "^-" | wc
12 108 751
[root@hadoop1 newdisk]# ls -l /home |grep "^-" | wc -l
12
[root@hadoop1 newdisk]# cd ../
[root@hadoop1 home]# ls -l /home |grep "^-" | wc -l
12
[root@hadoop1 home]# ls -l /home |grep "^d" | wc -l
15
[root@hadoop1 home]# ls -lR /home |grep "^-" | wc -l
29
[root@hadoop1 home]# ls -lR /home |grep "^d" | wc -l
17
[root@hadoop1 home]# yum install tree
[root@hadoop1 home]# tree
.
├── a1.txt
├── a2.txt
├── abc.txt
├── a.tar.gz
├── a.txt
├── fox
├── haha
│ └── haha.txt
├── haha.txt
├── hello.txt
├── hihi.txt
├── jack
│ └── jack01.txt
├── jerry
├── kkk
│ ├── aaa.txt
│ ├── bbb.txt
│ ├── ccc.txt
│ └── mytask.sh
├── myhome.tar.gz
├── mypackage.zip
├── mytask1.sh
├── mytask2.sh
├── newdisk
│ └── lost+found
├── test
│ ├── a.txt
│ ├── b.txt
│ └── c.txt
├── tiger
├── tom
│ ├── abc
│ ├── abc.txt
│ └── ok.txt
├── xh
├── xiaoming
├── xq
├── zhangfei
├── zhangquji
└── zwj
├── b.txt
├── c.txt
└── test
├── a.txt
├── b.txt
└── c.txt
17 directories, 29 files
修改IP(修改虚拟网络的IP)
查看网卡:
(2)使用命令查看:
(1)使用ipconfig查看
(2)界面查看
ping测试主机之间网络互通:ping 目的主机
第一种方法:自动获取,即登录后通过界面来设置自动获取ip
linu启动后会自动获取ip,缺点是每次获取的ip不一样。
不适用于做服务器,因为服务器的ip是固定的
[root@hadoop1 桌面]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:AA:65
inet addr:192.168.157.128 Bcast:192.168.157.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1f:aa65/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8316 errors:0 dropped:0 overruns:0 frame:0
TX packets:3857 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9789596 (9.3 MiB) TX bytes:236450 (230.9 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)
[root@hadoop1 桌面]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@hadoop1 桌面]# service network restart
正在关闭接口 eth0: 设备状态:3 (断开连接)
[确定]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0: 活跃连接状态:激活中
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/1
状态:激活的
连接被激活
[确定]
[root@hadoop1 桌面]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:AA:65
inet addr:192.168.157.128 Bcast:192.168.157.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1f:aa65/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8627 errors:0 dropped:0 overruns:0 frame:0
TX packets:3879 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9808941 (9.3 MiB) TX bytes:238324 (232.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)
[root@hadoop1 桌面]# ping www.baidu.com
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174: icmp_seq=1 ttl=128 time=34.6 ms
64 bytes from 183.232.231.174: icmp_seq=2 ttl=128 time=31.9 ms
--- www.a.shifen.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 8221ms
rtt min/avg/max/mdev = 31.952/37.459/43.905/4.584 ms
[root@hadoop1 桌面]# ping 192.168.2.109
PING 192.168.2.109 (192.168.2.109) 56(84) bytes of data.
64 bytes from 192.168.2.109: icmp_seq=1 ttl=128 time=1.32 ms
--- 192.168.2.109 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3771ms
rtt min/avg/max/mdev = 1.158/1.229/1.325/0.080 ms
[root@hadoop1 桌面]#