Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
open-iscsiとiscsitargetのinstallログ
~:$ ssh -l root localhost -p 2223
The authenticity of host '[localhost]:2223 ([127.0.0.1]:2223)' can't be established.
RSA key fingerprint is 5e:80:92:fa:82:60:05:09:89:c1:39:6b:72:30:d5:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:2223' (RSA) to the list of known hosts.
root@localhost's password:
Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Jan 8 04:47:21 2014
root@debian:~# aptitude search iscsi
p iscsitarget - iSCSI Enterprise Target userland tools
p iscsitarget-dkms - iSCSI Enterprise Target kernel module source - dkms version
p libiscsi-bin - iSCSI client shared library - utilities
p libiscsi-dev - iSCSI client shared library
p libiscsi1 - iSCSI client shared library
p open-iscsi - High performance, transport independent iSCSI implementation
root@debian:~# aptitude install iscsitarget iscsitarget-dkms
The following NEW packages will be installed:
binutils{a} cpp{a} cpp-4.6{a} cpp-4.7{a} dkms{a} fakeroot{a} gcc{a} gcc-4.6{a} gcc-4.6-base{a} gcc-4.7{a} iscsitarget iscsitarget-dkms libc-dev-bin{a} libc6-dev{a} libgmp10{a} libgomp1{a} libitm1{a} libmpc2{a}
libmpfr4{a} libquadmath0{a} linux-headers-3.2.0-4-amd64{a} linux-headers-3.2.0-4-common{a} linux-headers-amd64{a} linux-kbuild-3.2{a} linux-libc-dev{a} make{a} manpages-dev{a} menu{a}
0 packages upgraded, 28 newly installed, 0 to remove and 59 not upgraded.
Need to get 42.9 MB of archives. After unpacking 117 MB will be used.
Do you want to continue? [Y/n/?]
Get: 1 http://ftp.debian.org/debian/ wheezy/main libgmp10 amd64 2:5.0.5+dfsg-2 [250 kB]
Get: 2 http://ftp.debian.org/debian/ wheezy/main libgomp1 amd64 4.7.2-5 [27.5 kB]
Get: 3 http://ftp.debian.org/debian/ wheezy/main libitm1 amd64 4.7.2-5 [36.6 kB]
Get: 4 http://ftp.debian.org/debian/ wheezy/main libmpfr4 amd64 3.1.0-5 [538 kB]
Get: 5 http://ftp.debian.org/debian/ wheezy/main libquadmath0 amd64 4.7.2-5 [125 kB]
Get: 6 http://ftp.debian.org/debian/ wheezy/main libmpc2 amd64 0.9-4 [40.1 kB]
Get: 7 http://ftp.debian.org/debian/ wheezy/main binutils amd64 2.22-8 [4,800 kB]
Get: 8 http://ftp.debian.org/debian/ wheezy/main cpp-4.7 amd64 4.7.2-5 [5,416 kB]
Get: 9 http://ftp.debian.org/debian/ wheezy/main cpp amd64 4:4.7.2-1 [16.6 kB]
Get: 10 http://ftp.debian.org/debian/ wheezy/main gcc-4.6-base amd64 4.6.3-14 [142 kB]
Get: 11 http://ftp.debian.org/debian/ wheezy/main cpp-4.6 amd64 4.6.3-14 [4,828 kB]
Get: 12 http://ftp.debian.org/debian/ wheezy/main gcc-4.7 amd64 4.7.2-5 [8,296 kB]
Get: 13 http://ftp.debian.org/debian/ wheezy/main gcc amd64 4:4.7.2-1 [5,064 B]
Get: 14 http://ftp.debian.org/debian/ wheezy/main make amd64 3.81-8.2 [396 kB]
Get: 15 http://ftp.debian.org/debian/ wheezy/main dkms all 2.2.0.3-1.2 [77.4 kB]
Get: 16 http://ftp.debian.org/debian/ wheezy/main fakeroot amd64 1.18.4-2 [109 kB]
Get: 17 http://ftp.debian.org/debian/ wheezy/main gcc-4.6 amd64 4.6.3-14 [7,325 kB]
Get: 18 http://ftp.debian.org/debian/ wheezy/main iscsitarget amd64 1.4.20.2-10.1 [78.3 kB]
Get: 19 http://ftp.debian.org/debian/ wheezy/main iscsitarget-dkms all 1.4.20.2-10.1 [75.5 kB]
Get: 20 http://ftp.debian.org/debian/ wheezy/main libc-dev-bin amd64 2.13-38 [224 kB]
Get: 21 http://ftp.debian.org/debian/ wheezy/main linux-libc-dev amd64 3.2.51-1 [812 kB]
Get: 22 http://ftp.debian.org/debian/ wheezy/main libc6-dev amd64 2.13-38 [2,660 kB]
Get: 23 http://ftp.debian.org/debian/ wheezy/main linux-headers-3.2.0-4-common amd64 3.2.51-1 [3,565 kB]
Get: 24 http://ftp.debian.org/debian/ wheezy/main linux-kbuild-3.2 amd64 3.2.17-1 [238 kB]
Get: 25 http://ftp.debian.org/debian/ wheezy/main linux-headers-3.2.0-4-amd64 amd64 3.2.51-1 [605 kB]
Get: 26 http://ftp.debian.org/debian/ wheezy/main linux-headers-amd64 amd64 3.2+46 [4,450 B]
Get: 27 http://ftp.debian.org/debian/ wheezy/main manpages-dev all 3.44-1 [1,737 kB]
Get: 28 http://ftp.debian.org/debian/ wheezy/main menu amd64 2.1.46 [480 kB] [68/124]
Fetched 42.9 MB in 1min 52s (383 kB/s)
Selecting previously unselected package libgmp10:amd64.
(Reading database ... 24399 files and directories currently installed.)
Unpacking libgmp10:amd64 (from .../libgmp10_2%3a5.0.5+dfsg-2_amd64.deb) ...
Selecting previously unselected package libgomp1:amd64.
Unpacking libgomp1:amd64 (from .../libgomp1_4.7.2-5_amd64.deb) ...
Selecting previously unselected package libitm1:amd64.
Unpacking libitm1:amd64 (from .../libitm1_4.7.2-5_amd64.deb) ...
Selecting previously unselected package libmpfr4:amd64.
Unpacking libmpfr4:amd64 (from .../libmpfr4_3.1.0-5_amd64.deb) ...
Selecting previously unselected package libquadmath0:amd64.
Unpacking libquadmath0:amd64 (from .../libquadmath0_4.7.2-5_amd64.deb) ...
Selecting previously unselected package libmpc2:amd64.
Unpacking libmpc2:amd64 (from .../libmpc2_0.9-4_amd64.deb) ...
Selecting previously unselected package binutils.
Unpacking binutils (from .../binutils_2.22-8_amd64.deb) ...
Selecting previously unselected package cpp-4.7.
Unpacking cpp-4.7 (from .../cpp-4.7_4.7.2-5_amd64.deb) ...
Selecting previously unselected package cpp.
Unpacking cpp (from .../cpp_4%3a4.7.2-1_amd64.deb) ...
Selecting previously unselected package gcc-4.6-base:amd64.
Unpacking gcc-4.6-base:amd64 (from .../gcc-4.6-base_4.6.3-14_amd64.deb) ...
Selecting previously unselected package cpp-4.6.
Unpacking cpp-4.6 (from .../cpp-4.6_4.6.3-14_amd64.deb) ...
Selecting previously unselected package gcc-4.7.
Unpacking gcc-4.7 (from .../gcc-4.7_4.7.2-5_amd64.deb) ...
Selecting previously unselected package gcc.
Unpacking gcc (from .../gcc_4%3a4.7.2-1_amd64.deb) ...
Selecting previously unselected package make.
Unpacking make (from .../make_3.81-8.2_amd64.deb) ...
Selecting previously unselected package dkms.
Unpacking dkms (from .../dkms_2.2.0.3-1.2_all.deb) ...
Selecting previously unselected package fakeroot.
Unpacking fakeroot (from .../fakeroot_1.18.4-2_amd64.deb) ...
Selecting previously unselected package gcc-4.6.
Unpacking gcc-4.6 (from .../gcc-4.6_4.6.3-14_amd64.deb) ...
Selecting previously unselected package iscsitarget.
Unpacking iscsitarget (from .../iscsitarget_1.4.20.2-10.1_amd64.deb) ...
Selecting previously unselected package iscsitarget-dkms.
Unpacking iscsitarget-dkms (from .../iscsitarget-dkms_1.4.20.2-10.1_all.deb) ...
Selecting previously unselected package libc-dev-bin.
Unpacking libc-dev-bin (from .../libc-dev-bin_2.13-38_amd64.deb) ...
Selecting previously unselected package linux-libc-dev:amd64.
Unpacking linux-libc-dev:amd64 (from .../linux-libc-dev_3.2.51-1_amd64.deb) ...
Selecting previously unselected package libc6-dev:amd64.
Unpacking libc6-dev:amd64 (from .../libc6-dev_2.13-38_amd64.deb) ...
Selecting previously unselected package linux-headers-3.2.0-4-common.
Unpacking linux-headers-3.2.0-4-common (from .../linux-headers-3.2.0-4-common_3.2.51-1_amd64.deb) ...
Selecting previously unselected package linux-kbuild-3.2.
Unpacking linux-kbuild-3.2 (from .../linux-kbuild-3.2_3.2.17-1_amd64.deb) ...
Selecting previously unselected package linux-headers-3.2.0-4-amd64.
Unpacking linux-headers-3.2.0-4-amd64 (from .../linux-headers-3.2.0-4-amd64_3.2.51-1_amd64.deb) ...
Selecting previously unselected package linux-headers-amd64. [15/124]
Unpacking linux-headers-amd64 (from .../linux-headers-amd64_3.2+46_amd64.deb) ...
Selecting previously unselected package manpages-dev.
Unpacking manpages-dev (from .../manpages-dev_3.44-1_all.deb) ...
Selecting previously unselected package menu.
Unpacking menu (from .../archives/menu_2.1.46_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Setting up libgmp10:amd64 (2:5.0.5+dfsg-2) ...
Setting up libgomp1:amd64 (4.7.2-5) ...
Setting up libitm1:amd64 (4.7.2-5) ...
Setting up libmpfr4:amd64 (3.1.0-5) ...
Setting up libquadmath0:amd64 (4.7.2-5) ...
Setting up libmpc2:amd64 (0.9-4) ...
Setting up binutils (2.22-8) ...
Setting up cpp-4.7 (4.7.2-5) ...
Setting up cpp (4:4.7.2-1) ...
Setting up gcc-4.6-base:amd64 (4.6.3-14) ...
Setting up cpp-4.6 (4.6.3-14) ...
Setting up gcc-4.7 (4.7.2-5) ...
Setting up gcc (4:4.7.2-1) ...
Setting up make (3.81-8.2) ...
Setting up dkms (2.2.0.3-1.2) ...
Setting up fakeroot (1.18.4-2) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up gcc-4.6 (4.6.3-14) ...
Setting up iscsitarget (1.4.20.2-10.1) ...
iscsitarget not enabled in "/etc/default/iscsitarget", not starting... ... (warning).
Setting up iscsitarget-dkms (1.4.20.2-10.1) ...
Creating symlink /var/lib/dkms/iscsitarget/1.4.20.2/source ->
/usr/src/iscsitarget-1.4.20.2
DKMS: add completed.
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=3.2.0-4-amd64 -C /lib/modules/3.2.0-4-amd64/build M=/var/lib/dkms/iscsitarget/1.4.20.2/build......
cleaning build area....
DKMS: build completed.
iscsi_trgt:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/3.2.0-4-amd64/updates/dkms/
depmod.....
DKMS: install completed.
Setting up libc-dev-bin (2.13-38) ...
Setting up linux-libc-dev:amd64 (3.2.51-1) ...
Setting up libc6-dev:amd64 (2.13-38) ...
Setting up linux-headers-3.2.0-4-common (3.2.51-1) ...
Setting up linux-kbuild-3.2 (3.2.17-1) ...
Setting up linux-headers-3.2.0-4-amd64 (3.2.51-1) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.2.0-4-amd64
Setting up linux-headers-amd64 (3.2+46) ...
Setting up manpages-dev (3.44-1) ...
Setting up menu (2.1.46) ...
Processing triggers for menu ...
root@debian:~# dpkg -L iscsitarget
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/iscsitarget
/usr/share/doc/iscsitarget/NEWS.Debian.gz
/usr/share/doc/iscsitarget/copyright
/usr/share/doc/iscsitarget/README.gz
/usr/share/doc/iscsitarget/README.Debian
/usr/share/doc/iscsitarget/changelog.Debian.gz
/usr/share/doc/iscsitarget/changelog.gz
/usr/share/doc/iscsitarget/README.vmware
/usr/share/man
/usr/share/man/man5
/usr/share/man/man5/ietd.conf.5.gz
/usr/share/man/man8
/usr/share/man/man8/ietadm.8.gz
/usr/share/man/man8/ietd.8.gz
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/iscsitarget
/usr/sbin
/usr/sbin/ietadm
/usr/sbin/ietd
/etc
/etc/init.d
/etc/init.d/iscsitarget
/etc/default
/etc/default/iscsitarget
/etc/iet
/etc/iet/initiators.allow
/etc/iet/ietd.conf
/etc/iet/targets.allow
root@debian:~# cat /etc/default/iscsitarget
ISCSITARGET_ENABLE=false
# ietd options
# See ietd(8) for details
ISCSITARGET_OPTIONS=""
root@debian:~# sed -i.old -e "s/false/true/" /etc/default/iscsitarget
root@debian:~# dd if=/dev/zero of=disk.img bs=1 count=0 seek=1G
0+0 records in
0+0 records out
0 bytes (0 B) copied, 5.247e-06 s, 0.0 kB/s
root@debian:~# ls -lh
total 0
-rw-r--r-- 1 root root 1.0G Jan 8 06:24 disk.img
root@debian:~# echo "Target iqn.2014-01.localhost:fileio.test
> Lun 0 Path=`pwd`/disk.img,Type=fileio,ScsiId=test,ScsiSN=test" >> /etc/iet/ietd.conf
root@debian:~# tail /etc/iet/ietd.conf
# If 0 or > NOPInterval, NOPInterval
# is used!
#
# Various target parameters
#
#Wthreads 8 # Number of IO threads
#QueuedCommands 32 # Number of queued commands
Target iqn.2014-01.localhost:fileio.test
Lun 0 Path=/root/disk.img,Type=fileio,ScsiId=test,ScsiSN=test
root@debian:~# service iscsitarget restart
Removing iSCSI enterprise target devices: :.
Starting iSCSI enterprise target service:.
.
root@debian:~# dmesg | tail
[ 995.952180] e1000: eth0 NIC Link is Down
[ 999.960645] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[ 2138.241594] e1000: eth0 NIC Link is Down
[ 2142.249998] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[ 3444.949429] e1000: eth0 NIC Link is Down
[ 3450.960563] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[ 6214.828691] iSCSI Enterprise Target Software - version 1.4.20.3
[ 6214.828739] iscsi_trgt: Registered io type fileio
[ 6214.828741] iscsi_trgt: Registered io type blockio
[ 6214.828743] iscsi_trgt: Registered io type nullio
root@debian:~# lsof | grep iscsi
ietd 8510 root 7u IPv4 11888 0t0 TCP *:iscsi-target (LISTEN)
ietd 8510 root 8u IPv6 11889 0t0 TCP *:iscsi-target (LISTEN)
root@debian:~# lsof -c ietd
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ietd 8510 root cwd DIR 8,1 4096 2 /
ietd 8510 root rtd DIR 8,1 4096 2 /
ietd 8510 root txt REG 8,1 78208 273284 /usr/sbin/ietd
ietd 8510 root mem REG 8,1 1595408 391699 /lib/x86_64-linux-gnu/libc-2.13.so
ietd 8510 root mem REG 8,1 136936 391702 /lib/x86_64-linux-gnu/ld-2.13.so
ietd 8510 root 0u CHR 1,3 0t0 1205 /dev/null
ietd 8510 root 1u CHR 1,3 0t0 1205 /dev/null
ietd 8510 root 2u CHR 1,3 0t0 1205 /dev/null
ietd 8510 root 3wW REG 0,14 5 11882 /run/ietd.pid
ietd 8510 root 4u unix 0xffff88001f5440c0 0t0 11883 @IET_ABSTRACT_NAMESPACE
ietd 8510 root 5u CHR 251,0 0t0 11884 /dev/ietctl
ietd 8510 root 6u netlink 0t0 11885 unknown protocol: 21
ietd 8510 root 7u IPv4 11888 0t0 TCP *:iscsi-target (LISTEN)
ietd 8510 root 8u IPv6 11889 0t0 TCP *:iscsi-target (LISTEN)
root@debian:~# netstat -anp | grep iet
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 8510/ietd
tcp6 0 0 :::3260 :::* LISTEN 8510/ietd
unix 2 [ ACC ] STREAM LISTENING 11883 8510/ietd @IET_ABSTRACT_NAMESPACE
root@debian:~#
root@debian:~# aptitude search iscsi
i iscsitarget - iSCSI Enterprise Target userland tools
i iscsitarget-dkms - iSCSI Enterprise Target kernel module source - dkms version
p libiscsi-bin - iSCSI client shared library - utilities
p libiscsi-dev - iSCSI client shared library
p libiscsi1 - iSCSI client shared library
p open-iscsi - High performance, transport independent iSCSI implementation
root@debian:~# aptitude install open-iscsi
The following NEW packages will be installed:
open-iscsi
0 packages upgraded, 1 newly installed, 0 to remove and 59 not upgraded.
Need to get 532 kB of archives. After unpacking 2,166 kB will be used.
Get: 1 http://ftp.debian.org/debian/ wheezy/main open-iscsi amd64 2.0.873-3 [532 kB]
Fetched 532 kB in 3s (165 kB/s)
Selecting previously unselected package open-iscsi.
(Reading database ... 37198 files and directories currently installed.)
Unpacking open-iscsi (from .../open-iscsi_2.0.873-3_amd64.deb) ...
Processing triggers for man-db ...
Setting up open-iscsi (2.0.873-3) ...
root@debian:~# dpkg -L open-iscsi
/.
/etc
/etc/default
/etc/default/open-iscsi
/etc/init.d
/etc/init.d/open-iscsi
/etc/init.d/umountiscsi.sh
/etc/iscsi
/etc/iscsi/iscsid.conf
/etc/iscsi/initiatorname.iscsi
/etc/network
/etc/network/if-up.d
/var
/var/lib
/var/lib/open-iscsi
/usr
/usr/share
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/iscsistart.8.gz
/usr/share/man/man8/iscsi_discovery.8.gz
/usr/share/man/man8/iscsi-iname.8.gz
/usr/share/man/man8/iscsiadm.8.gz
/usr/share/man/man8/iscsid.8.gz
/usr/share/doc
/usr/share/doc/open-iscsi
/usr/share/doc/open-iscsi/README.gz
/usr/share/doc/open-iscsi/copyright
/usr/share/doc/open-iscsi/changelog.Debian.gz
/usr/share/doc/open-iscsi/README.Debian.gz
/usr/share/doc/open-iscsi/changelog.gz
/usr/share/initramfs-tools
/usr/share/initramfs-tools/hooks
/usr/share/initramfs-tools/hooks/iscsi
/usr/share/initramfs-tools/scripts
/usr/share/initramfs-tools/scripts/local-top
/usr/share/initramfs-tools/scripts/local-top/iscsi
/usr/sbin
/usr/sbin/iscsistart
/usr/sbin/iscsi-iname
/usr/sbin/iscsid
/usr/sbin/iscsi_discovery
/usr/bin
/usr/bin/iscsiadm
root@debian:~# iscsiadm
Try `iscsiadm --help' for more information.
root@debian:~# iscsiadm --help
iscsiadm -m discoverydb [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -Dl ] ] | [ [ -p ip:port -t type] [ -o operation ] [ -n name ] [ -v value ] [ -lD ] ]
iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ [ -p ip:port ] [ -l | -D ] ]
iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,automatic ] [ -U all,manual,automatic ] [ -S ] [ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u | -R | -s] ] [ [ -o operation ] [ -n name ] [ -v value ] ]
iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]
iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o operation ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]
iscsiadm -m fw [ -l ]
iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ -C chap [ -o operation ] [ -v chap_tbl_idx ] ]
iscsiadm -k priority
root@debian:~# iscsiadm -m discovery -t sendtargets -p localhost
[::1]:3260,1 iqn.2014-01.localhost:fileio.test
[fe80::a00:27ff:fe98:1f49]:3260,1 iqn.2014-01.localhost:fileio.test
root@debian:~# iscsiadm -m discovery -t sendtargets -p 127.0.0.1
127.0.0.1:3260,1 iqn.2014-01.localhost:fileio.test
10.0.2.15:3260,1 iqn.2014-01.localhost:fileio.test
root@debian:~# iscsiadm -m node -p 127.0.0.1 -l
Logging in to [iface: default, target: iqn.2014-01.localhost:fileio.test, portal: 127.0.0.1,3260] (multiple)
Login to [iface: default, target: iqn.2014-01.localhost:fileio.test, portal: 127.0.0.1,3260] successful.
root@debian:~# dmesg | tail
[ 6214.828743] iscsi_trgt: Registered io type nullio
[ 6484.501041] scsi3 : iSCSI Initiator over TCP/IP
[ 6484.764505] scsi 3:0:0:0: Direct-Access IET VIRTUAL-DISK 0 PQ: 0 ANSI: 4
[ 6484.765289] sd 3:0:0:0: [sdb] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB)
[ 6484.765325] sd 3:0:0:0: [sdb] Write Protect is off
[ 6484.765328] sd 3:0:0:0: [sdb] Mode Sense: 77 00 00 08
[ 6484.765389] sd 3:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 6484.766030] sdb: unknown partition table
[ 6484.766303] sd 3:0:0:0: [sdb] Attached SCSI disk
[ 6484.766417] sd 3:0:0:0: Attached scsi generic sg2 type 0
root@debian:~# 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 0x86017ce7.
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)
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x86017ce7
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x28f08f9a
Device Boot Start End Blocks Id System
/dev/sdb1 2048 2097151 1047552 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@debian:~# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 261888 blocks
13094 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
root@debian:~# mkdir mount
root@debian:~# mount /dev/sdb1 mount/
root@debian:~# ls mount/
lost+found
root@debian:~# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 19G 1022M 17G 6% /
udev 10M 0 10M 0% /dev
tmpfs 50M 240K 50M 1% /run
/dev/disk/by-uuid/f5aa3b2c-46ae-4b43-8191-1173de38f1d8 19G 1022M 17G 6% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 276M 0 276M 0% /run/shm
/dev/sdb1 1007M 18M 939M 2% /root/mount
root@debian:~# dmesg | tail
[ 6484.765325] sd 3:0:0:0: [sdb] Write Protect is off
[ 6484.765328] sd 3:0:0:0: [sdb] Mode Sense: 77 00 00 08
[ 6484.765389] sd 3:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 6484.766030] sdb: unknown partition table
[ 6484.766303] sd 3:0:0:0: [sdb] Attached SCSI disk
[ 6484.766417] sd 3:0:0:0: Attached scsi generic sg2 type 0
[ 6575.135074] sdb: sdb1
[ 6682.438236] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
root@debian:~#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment