aquaballoon

System Tweak

May 23rd, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.50 KB | None | 0 0
  1. Finding Some System Info
  2.  
  3. Load, statistics and messages -- useful to find out what is happening in your system
  4.  
  5. # displays and updates the top cpu processes
  6. Code:top
  7.  
  8. # displays your processors related statistics -- install via apt-get install sysstat
  9. Code:mpstat 1
  10.  
  11. # displays your virtual memory statistics
  12. Code:vmstat 2
  13.  
  14. # display I/O statistics (2 s intervals) -- also installed via sysstat
  15. Code:iostat 2
  16.  
  17. # Last 500 kernel/syslog messages
  18. Code:tail -n 500 /var/log/syslog
  19.  
  20. # Last 500 kernel/syslog messages
  21. Code:tail -n 500 /var/log/messages
  22.  
  23. # System warnings messages see syslog.conf
  24. Code:tail /var/log/warn
  25.  
  26. Running kernel and basic system information
  27.  
  28. # Get the kernel version -- Use uname --help for variations of this command
  29. Code:uname -a
  30.  
  31. # Show how long the system has been running and CPU load
  32. Code:uptime
  33.  
  34. # system's host name
  35. Code:hostname
  36.  
  37. # Display the IP address of the host
  38. Code:hostname -i
  39.  
  40. # Description of the file system hierarchy
  41. Code:man hier
  42.  
  43. # Show system reboot history
  44. Code:last reboot
  45.  
  46. # Full release info of any LSB distribution
  47. Code:lsb_release -a
  48.  
  49. # Get Debian version (yes ubuntu gives one, it is based on debian)
  50. Code:cat /etc/debian_version
  51.  
  52. Information about your Hardware
  53.  
  54. Kernel detected hardware
  55.  
  56. # Detected hardware and boot messages
  57. Code:dmesg
  58.  
  59. # information about installed hardware
  60. Code:lsdev
  61.  
  62. # Read the BIOS
  63. Code:dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
  64.  
  65. # Shows PCI devices
  66. Code:lspci
  67.  
  68. # Shows USB devices
  69. Code:lsusb
  70.  
  71. # Shows DMI/SMBIOS info (hardware information from the BIOS)
  72. Code:dmidecode
  73.  
  74. # Show a list of all devices with their properties
  75. Code:lshal
  76.  
  77. # Shows a list of connected hardware
  78. Code:lshw
  79.  
  80. # Information about your CPU
  81. Code:nano -w /proc/cpuinfo
  82.  
  83. # Info about your hardware memory
  84. Code:nano -w /proc/meminfo
  85.  
  86. # Displays your physical memory
  87. Code:grep MemTotal /proc/meminfo
  88.  
  89. # Watch changeable interrupts continuously -- Watch -n1 is very useful to watch any changing file
  90. Code:watch -n1 'nano -w /proc/interrupts'
  91.  
  92. # Used and free memory (-m for MB)
  93. Code:free -m
  94.  
  95. # Configured devices
  96. Code:nano -w /proc/devices
  97.  
  98. Commands for Users and Controlling them
  99.  
  100. # Shows the active user id with login and group
  101. Code:id
  102.  
  103. # Shows last logins on the system
  104. Code:last
  105.  
  106. # Shows who is logged on the system
  107. Code:who
  108.  
  109. # Shows last boot time
  110. Code:who -b
  111.  
  112. # Add group "admin"
  113. Code:groupadd admin
  114.  
  115. # Adds user Joe Bloggs to group admin
  116. Code:useradd -c "Joe Bloggs" -g admin -m joe
  117.  
  118. # Add existing user to group
  119. Code:usermod -a -G <group> <user>
  120.  
  121. # Delete user joe
  122. Code:userdel Joe
  123.  
  124. To temporarily prevent logins system wide (for all users but root) use nologin.
  125. The message in nologin will be displayed (might not work with ssh pre-shared keys).
  126.  
  127. # Replace Sorry no login now for the message you would like to display
  128. Code:echo "Sorry no login now" > /etc/nologin
  129.  
  130. Limits
  131.  
  132. Some applications require higher limits on open files and sockets. The default limits are sometimes too low.
  133.  
  134. Per shell/script
  135.  
  136. The shell limits are governed by ulimit. The status is checked
  137. with ulimit -a. For example to change the open files limit from
  138. 1024 to 10240 do:
  139. Code:ulimit -n 10240
  140.  
  141. The ulimit command can be used in a script to change the limits for the script only.
  142.  
  143. Per user/process
  144.  
  145. Login users and applications can be configured in /etc/security/limits.conf. For example:
  146.  
  147. Code:nano -w /etc/security/limits.conf
  148.  
  149. # Limit user processes
  150. Code:*   hard    nproc   250
  151.  
  152. # Limit application open files
  153. Code:asterisk hard nofile 409600
  154.  
  155. System wide limits
  156.  
  157. Kernel limits are set with sysctl. Permanent limits are set in /etc/sysctl.conf.
  158.  
  159. # View all system limits
  160. Code:sysctl -a
  161.  
  162. # View max open files limit
  163. Code:sysctl fs.file-max
  164.  
  165. # Change max open files limit
  166. Code:sysctl fs.file-max=102400
  167.  
  168. # port range
  169. Code:echo "1024 50000" > /proc/sys/net/ipv4/ip_local_port_range
  170.  
  171. Code:nano -w /etc/sysctl.conf
  172.  
  173. # Permanent entry in sysctl.conf
  174. Code:fs.file-max=10240
  175.  
  176. # How many file descriptors are in use
  177. Code:nano -w /proc/sys/fs/file-nr
  178.  
  179. Runlevels
  180.  
  181.  
  182. Once booted, the kernel starts init which then starts rc which starts all scripts belonging to a runlevel.
  183. The scripts are stored in /etc/init.d and are linked into /etc/rc.d/rc#.d with # the runlevel number.
  184.  
  185. The actual runlevel can be changed with init. For example to go from 3 to 5:
  186.  
  187. # Enters runlevel 5
  188. Code:init 5
  189.  
  190. Runlevel list
  191.  
  192. * 0 Shutdown and halt
  193.  
  194. * 1 Single-User mode (also S)
  195.  
  196. * 2 Multi-user without network
  197.  
  198. * 3 Multi-user with network
  199.  
  200. * 5 Multi-user with X
  201.  
  202. * 6 Reboot
  203.  
  204. The above is for what most linux OSs do, however, debian acts slightly differently:
  205.  
  206. * 0 System Halt
  207.  
  208. * 1 Single User
  209.  
  210. * 2 Full multi-user mode (Default)
  211.  
  212. * 3-5 Same as 2
  213.  
  214. * 6 System Reboot
  215.  
  216. Debian and systems based on Debain, use the command update-rc.d to manage runlevels scripts.
  217. Default is to start in 2, 3, 4 and 5 and shutdown in 0, 1 and 6.
  218.  
  219. in the following examples, i will use sshd (the ssh server)
  220.  
  221. # Activates samba in the default runlevel
  222. Code:update-rc.d sshd defaults
  223.  
  224. # For use with explicit arguments
  225. Code:update-rc.d sshd start 20 2 3 4 5 . stop 20 0 1 6 .
  226.  
  227. # Disable sshd for all runlevels
  228. Code:update-rc.d -f sshd remove
  229.  
  230. # Shuts down and halts the system -- 'now' can be replace with a number # (# minutes from now)
  231. Code:shutdown -h now
  232.  
  233. Also, debian tends to want to use a tool called 'telinit' to switch init modes.
  234. i.e. #switches to runlevel 3
  235. Code:telinit 3
  236.  
  237. Also, take caution. Whilst you can issue telinit 6 to issue a shutdown... it really is not recommended.
  238.  
  239.  
  240. Resetting your root password
  241.  
  242. EDIT: Has been removed due to this forum policy: http://ubuntuforums.org/showthread.php?t=765414 (thanks Rocket2DMn)
  243.  
  244. Kernel
  245.  
  246. Kernel modules
  247.  
  248. # Lists all modules loaded into the kernel
  249. Code:lsmod
  250.  
  251. # To load a module -- I used ndiswrapper here
  252. Code:modprobe ndiswrapper
  253.  
  254. # To unload a module
  255. Code:rmmod nidiswrapper
  256.  
  257. Compiling your Kernel
  258.  
  259. # Changes Directory to the current kernel source -- verify the directory with ls -l, and create if necessary with ln -s
  260. Code:cd /usr/src/linux
  261.  
  262. # Cleans everything, including config files
  263. Code:make mrproper
  264.  
  265. # Reuses the old .config if it exists
  266. Code:make oldconfig
  267.  
  268. # or xconfig or gconfig, depending on personal preference
  269. Code:make menuconfig
  270.  
  271. # Creates a compressed kernel image
  272. Code:make
  273.  
  274. # Compiles the modules
  275. Code:make modules
  276.  
  277. # Installs the modules
  278. Code:make modules_install
  279.  
  280. # Installs the kernel
  281. Code:make install
  282.  
  283. Listing and manipulating processes
  284.  
  285. Listing and manipulating processes
  286.  
  287. Each process has a unique number, a PID. A list of all running processes is retrieved with ps.
  288.  
  289. # List of all running processes
  290. Code:ps -A
  291.  
  292. # An Extensive list of all running processes
  293. Code:ps -auxefw
  294.  
  295. Many handy uses of ps involve a pipe (|) and grep:
  296.  
  297. # Looks for a process with cron -- may not actually be running, use ps -A for running commands.
  298. Code:ps axww | grep cron
  299.  
  300. # an example output -- in this case, cron is not running
  301. Code:15087 pts/2    R+     0:00 grep --colour=auto cron
  302.  
  303. # Finds all ssh PIDs without the grep pid
  304. Code:ps aux | grep 'ss[h]'
  305.  
  306. # Find the PIDs of processes by (part of) name
  307. Code:pgrep -l sshd
  308.  
  309. # Echos the PID of your shell
  310. Code:echo $$
  311.  
  312. # List processes using port 22 on TCP
  313. Code:fuser -va 22/tcp
  314.  
  315. # List processes accessing the /home partiton
  316. Code:fuser -va /home
  317.  
  318. # Trace system calls and signals
  319. Code:strace df
  320.  
  321. # Display the last 50 used commands
  322. Code:history | tail -50
  323.  
  324. Priorities
  325.  
  326. Change the priority of a running process with renice. Negative numbers have a higher priority,
  327. the lowest is -20 and "nice" have a positive value.
  328.  
  329. # Stronger priority on PID 1070
  330. Code:renice -5 1070
  331.  
  332. # Output would look something like the following:
  333. Code:1070: old priority 0, new priority -5
  334.  
  335. Start the process with a defined priority with nice. Positive is "nice" or weak,
  336. negative is strong scheduling priority. Make sure you know if /usr/bin/nice or
  337. the shell built-in is used (check with which nice).
  338.  
  339. # Stronger priority (/usr/bin/nice)
  340. Code:nice -n -5 top
  341.  
  342. # Weaker priority (/usr/bin/nice)
  343. Code:nice -n 5 top
  344.  
  345. # tcsh builtin nice (same as above)
  346. Code:nice +5 top
  347.  
  348. While nice changes the CPU scheduler, an other useful command ionice will schedule the disk IO.
  349. This is very useful for intensive IO application which can bring a machine to its knees while
  350. still in a lower priority. You can select a class (idle - best effort - real time),
  351. the man page is short and well explained.
  352.  
  353. # set idle class for pid 123
  354. Code:ionice c3 -p123
  355.  
  356. # Run firefox with best effort and high priority
  357. Code:ionice -c2 -n0 firefox
  358.  
  359. # Set the actual shell to idle priority
  360. Code:ionice -c3 -p$$
  361.  
  362. For example, the last command is very useful to compile or debug a large project.
  363. Every command launched from this shell will have a lower priority and will not disturb the system.
  364. $$ is your shell pid (use echo $$ to see the PID of your shell.).
  365.  
  366. Background/Foreground
  367.  
  368. When started from a shell, processes can be brought in the background and back to the foreground with <Ctrl>-<Z> (^Z),
  369. bg and fg. For example start two processes, bring them in the background, list the processes with jobs and bring one
  370. in the foreground.
  371. Code:ping google.com > ping.log
  372.  
  373. # ping is suspended (i.e stopped) with <Ctrl>-<Z>
  374. Code:^Z
  375.  
  376. # put in background and continues running
  377. Code:bg
  378.  
  379. # List processes in background
  380. Code:jobs -l
  381.  
  382. # example output:
  383. Code:
  384.  
  385. [1]  - 36232 Running                       ping google.com > ping.log
  386. [2]  + 36233 Suspended (tty output)        less /var/log/messages
  387.  
  388. # Bring process number 2 back in foreground
  389. Code:fg %2
  390.  
  391. Use nohup to start a process which has to keep running when the shell is closed (it is immune to hangups).
  392.  
  393. # Also needs the '&' to sub-task the ping
  394. Code:nohup ping -i 60 > ping.log &
  395.  
  396. Using top effectively
  397.  
  398. The program top displays running information of processes.
  399.  
  400. # runs top from the terminal
  401. Code:top
  402.  
  403. While top is running press the key h for a help overview. Useful keys are:
  404.  
  405.  
  406. * u [user name] To display only the processes belonging to the user. Use + or blank to see all users
  407.  
  408. * k [pid] Kill the process with pid.
  409.  
  410. * 1 To display all processors statistics (Linux only)
  411.  
  412. * R Toggle normal/reverse sort.
  413.  
  414.  
  415. Signals/Kill
  416.  
  417. Terminate or send a signal with kill or killall. Kill kills something with a PID, killall with the process name, see
  418. man kill and man killall for more info.
  419.  
  420. Code:ping -i 60 google.com > ping.log &
  421.  
  422. #PID of the ping process
  423. Code:[1] 4712
  424.  
  425. # same as kill -15 4712
  426. Code:kill -s TERM 4712
  427.  
  428. # Kill HUP processes by exact name
  429. Code:killall -1 httpd
  430.  
  431. # Kill TERM processes by (part of) name
  432. Code:pkill -9 http
  433.  
  434. # Kill TERM processes owned by www
  435. Code:pkill -TERM -u www
  436.  
  437. # Kill every process accessing /home (to umount)
  438. Code:fuser -k -TERM -m /home
  439.  
  440. Important signals are (use anything above signal 3 with caution):
  441.  
  442.  
  443. * 1 HUP (hang up)
  444.  
  445. * 2 INT (interrupt)
  446.  
  447. * 3 QUIT (quit)
  448.  
  449. * 9 KILL (non-catchable, non-ignorable kill)
  450.  
  451. * 15 TERM (software termination signal)
  452.  
  453. File Systems
  454. Permissions
  455.  
  456. Change permission and ownership with chmod and chown.
  457. The default umask can be changed for all users in /etc/profile.
  458. The default umask is usually 022. The umask is subtracted from 777,
  459. thus umask 022 results in a permission 0f 755:
  460.  
  461. 1 --x execute # Mode 764 = exec/read/write | read/write | read
  462. 2 -w- write # For: |-- Owner --| |- Group-| |Oth|
  463. 4 r-- read
  464. ugo=a u=user, g=group, o=others, a=everyone
  465.  
  466.  
  467. # MODE is of the form [ugoa]*([-+=]([rwxXst]))
  468. Code:chmod [OPTION] MODE[,MODE] FILE
  469.  
  470. # Restrict some-log -rw-r-----
  471. Code:chmod 640 /var/log/some-log
  472.  
  473. # Same as above
  474. Code:chmod u=rw,g=r,o= /var/log/some-log
  475.  
  476. # Recursive remove other readable for all users
  477. Code:chmod -R o-r /home/*
  478.  
  479. # Set SUID bit on executable (use with caution)
  480. Code:chmod u+s /path/to/app
  481.  
  482. # Find all programs with the SUID bit
  483. Code:find / -perm -u+s -print
  484.  
  485. # Change the user and group ownership of a file
  486. Code:chown user:group /path/to/file
  487.  
  488. # Change the group ownership of a file
  489. Code:chgrp group /path/to/file
  490.  
  491. # Change permissions to 640 for all files
  492. Code:chmod 640 `find ./ -type f -print`
  493.  
  494. # Change permissions to 751 for all directories
  495. Code:chmod 751 `find ./ -type d -print`
  496.  
  497. Disk information
  498.  
  499. # information about the IDE/ATA disk
  500. Code:hdparm -I /dev/sda
  501.  
  502. # Display and manipulate the partition table
  503. Code:fdisk /dev/sda
  504.  
  505. # Display the disk SMART info (must have a SMART compatible disk) -- install with apt-get install smartmontools
  506. Code:smartctl -a /dev/sda
  507.  
  508. System mount points
  509.  
  510. # Show mounted file-systems on the system
  511. Code:mount | column -t
  512.  
  513. # display free disk space and mounted devices (use -h to show in human readable format)
  514. Code:df
  515.  
  516. # Show all registered partitions
  517. Code:nano -w /proc/partitions
  518.  
  519. Disk usage
  520.  
  521. # Directory sizes as listing
  522. Code:du -sh *
  523.  
  524. # Total directory size of the current directory
  525. Code:du -csh
  526.  
  527. # Sort everything by size in kilobytes
  528. Code:du -ks * | sort -n -r
  529.  
  530. # Show files, biggest last
  531. Code:ls -lSr
  532.  
  533. Find out who has which files opened
  534.  
  535. This is useful to find out which file is blocking a partition which has to be unmounted and gives a typical error of:
  536.  
  537. # umount impossible because a file is locking home
  538. Code:umount /home/
  539. umount: unmount of /home
  540. failed:    Device busy
  541.  
  542. A lot of linux OSs can use fstat for this sort of thing, ubuntu appears not to have it, i will look for another tool for this
  543.  
  544.  
  545. Find opened log file (or other opened files), say for your Xorg log file:
  546.  
  547. Code:ps ax | grep Xorg | awk '{print $1}'
  548.  
  549. #example output:
  550. Code:1252
  551.  
  552. The file with inum 212042 is the only file in /var:
  553. Code:find -x /var -inum 212042
  554.  
  555. # example ouptut:
  556. Code:/var/log/Xorg.0.log
  557.  
  558. Find opened files on a mount point with fuser or lsof:
  559.  
  560. # List processes accessing /home
  561. Code:fuser -m /home
  562.  
  563. Code:lsof /home
  564.  
  565. #example output:
  566. COMMAND   PID    USER   FD   TYPE DEVICE    SIZE     NODE NAME
  567. tcsh    29029 joe  cwd    DIR   0,18   12288  1048587 /home/joe (guam:/home)
  568. lsof    29140 joe  cwd    DIR   0,18   12288  1048587 /home/joe (guam:/home)
  569.  
  570. About an application:
  571.  
  572. Code:ps ax | grep Xorg | awk '{print $1}'
  573.  
  574. # example output:
  575. Code:3324
  576.  
  577. Code:lsof -p 3324
  578.  
  579. #example output
  580. COMMAND   PID    USER   FD   TYPE DEVICE    SIZE    NODE NAME
  581. Xorg    3324 root    0w   REG        8,6   56296      12492 /var/log/Xorg.0.log
  582.  
  583. About a single file:
  584. Code:lsof /var/log/Xorg.0.log
  585.  
  586. # example output
  587. COMMAND  PID USER   FD   TYPE DEVICE  SIZE  NODE NAME
  588. Xorg    3324 root    0w   REG    8,6 56296 12492 /var/log/Xorg.0.log
  589.  
  590. Mount/remount a file system
  591.  
  592. For example, mounting your cdrom drive. If it is listed in /etc/fstab:
  593. Code:mount /dev/cdrom
  594.  
  595. if not
  596.  
  597. # typical ubuntu cdrom mount command
  598. Code:mount -t auto /dev/cdrom /media/cdrom
  599.  
  600. # typical IDE
  601. Code:mount /dev/hdc -t iso9660 -r /media/cdrom
  602.  
  603. # typical SCSI cdrom
  604. Code:mount /dev/scd0 -t iso9660 -r /media/cdrom
  605.  
  606. # typical SCSI -- must have ntfs-3g tool installed either install with apt-get
  607. Code:mount /dev/sdc0 -t ntfs-3g /media/windows
  608.  
  609. # or you could swap ntfs-3g with ntfs if you have the ntfs kernel module installed.
  610. Code:mount /dev/sdc0 -t ntfs /media/windows
  611.  
  612. Entry in /etc/fstab:
  613.  
  614. Code:/dev/cdrom   /media/cdrom  auto noauto,fs=cdfss,ro,procuid,nosuid,nodev,exec 0 0
  615.  
  616. Remount
  617.  
  618. Remount a device without unmounting it. Necessary for fsck for example
  619.  
  620. Code:mount -o remount,ro /
  621.  
  622. Copy the raw data from a cdrom into an iso image:
  623. Code:dd if=/dev/cdrom of=file.iso
  624.  
  625. Add swap on-the-fly
  626.  
  627. Suppose you need more swap (right now), say a 2GB file /swap2gb.
  628.  
  629. Code:dd if=/dev/zero of=/swap2gb bs=1024k count=2000
  630.  
  631. # create the swap area
  632. Code:mkswap /swap2gb
  633.  
  634. # activate the swap.
  635. Code:swapon /swap2gb
  636.  
  637. # when done deactivate the swap
  638. Code:swapoff /swap2gb
  639.  
  640. # remove the swap
  641. Code:rm /swap2gb
  642.  
  643. Mount a samba share
  644.  
  645. Suppose we want to access the SMB share myshare on the computer smbserver,
  646. the address as typed on a Windows PC is \\smbserver\myshare\.
  647. We mount on /mnt/smbshare. Warning> cifs wants an IP or DNS name, not a Windows name.
  648.  
  649. # List the shares
  650. Code:smbclient -U user -I 192.168.16.229 -L //smbshare/
  651.  
  652. Code:mount -t smbfs -o username=winuser //smbserver/myshare /mnt/smbshare
  653.  
  654. Code:mount -t cifs -o username=winuser,password=winpwd //192.168.16.229/myshare /mnt/share
  655.  
  656. Additionally with the package mount.cifs it is possible to store the credentials
  657. in a file, for example /home/user/.smb:
  658.  
  659. username=winuser
  660. password=winpwd
  661.  
  662.  
  663. And mount as follow:
  664.  
  665. Code:mount -t cifs -o credentials=/home/user/.smb //192.168.16.229/myshare /mnt/smbshare
  666.  
  667. Mount an image
  668.  
  669. # Mount a CD image
  670. Code:mount -t iso9660 -o loop file.iso /mnt/image
  671.  
  672. # Mount an image with ext3 fs[code]mount -t ext3 -o loop file.img /mnt/image [/code]Create and burn an ISO image
  673.  
  674. This will copy the cd or DVD sector for sector. Without conv=notrunc,
  675. the image will be smaller if there is less content on the cd.
  676. See below and the dd examples.
  677.  
  678. Code:dd if=/dev/cdrom of=/tmp/mycd.iso bs=2048 conv=notrunc
  679.  
  680. Use mkisofs to create a CD/DVD image from files in a directory.
  681. To overcome the file names restrictions: -r enables the Rock Ridge
  682. extensions common to UNIX systems, -J enables Joliet extensions used
  683. by Microsoft systems. -L allows ISO9660 filenames to begin with a period.
  684.  
  685. Code:mkisofs -J -L -r -V TITLE -o imagefile.iso /path/to/dir
  686.  
  687. Also use cdrecord with Linux as described above. Additionally it is possible to
  688. use the native ATAPI interface which is found with:
  689.  
  690. Code:cdrecord dev=ATAPI -scanbus
  691.  
  692. And burn the CD/DVD as above.
  693. dvd+rw-tools
  694.  
  695. The dvd+rw-tools package can do it all and includes growisofs to burn CDs or DVDs.
  696. The examples refere to the dvd device as /dev/dvd which could be a symlink to /dev/scd0
  697. (typical scsi on Linux), although you will probably want /dev/cdrom.
  698.  
  699. # -dvd-compat closes the disk
  700. # Burn existing iso image
  701.  
  702. Code:growisofs -dvd-compat -Z /dev/dvd=imagefile.iso
  703.  
  704. # Burn directly
  705. Code:growisofs -dvd-compat -Z /dev/dvd -J -R /p/to/data
  706.  
  707. Convert a Nero .nrg file to .iso
  708.  
  709. Nero simply adds a 300Kb header to a normal iso image. This can be removed with dd.
  710.  
  711. # Backup .nrg file first before doing this just in-case
  712. Code:dd bs=1k if=imagefile.nrg of=imagefile.iso skip=300
  713.  
  714. Convert a bin/cue image to .iso
  715.  
  716. The little bchunk programhttp://freshmeat.net/projects/bchunk/ can do this.
  717. Can install from the ubuntu repos with sudo apt-get install bchunk
  718.  
  719. Code:bchunk imagefile.bin imagefile.cue imagefile.iso
  720.  
  721. Create a file based image
  722.  
  723. Code:dd if=/dev/zero of=/usr/vdisk.img bs=1024k count=1024
  724.  
  725. Code:mkfs.ext3 /usr/vdisk.img
  726.  
  727. Code:mount -o loop /usr/vdisk.img /mnt/mountpoint
  728.  
  729. # Cleanup
  730. Code:umount /mnt; rm /usr/vdisk.img
  731.  
  732. Linux with losetup
  733.  
  734. /dev/zero is much faster than urandom, but less secure for encryption.
  735.  
  736. Code:dd if=/dev/urandom of=/usr/vdisk.img bs=1024k count=1024
  737.  
  738. # Creates and associates /dev/loop0
  739. Code:losetup /dev/loop0 /usr/vdisk.img
  740.  
  741. Code:mkfs.ext3 /dev/loop0
  742.  
  743. Code:mount /dev/loop0 /mnt
  744.  
  745. # Check used loops
  746. Code:losetup -a
  747.  
  748. Code:umount /mnt
  749.  
  750. # Detach
  751. Code:losetup -d /dev/loop0
  752.  
  753. Code:rm /usr/vdisk.img
  754.  
  755. Create a memory file system
  756.  
  757. A memory based file system is very fast for heavy IO application. How to create a 64 MB partition mounted on /memdisk:
  758.  
  759.  
  760. Code:mount -t tmpfs -osize=64m tmpfs /memdisk
  761.  
  762. Disk performance
  763.  
  764. Read and write a 1 GB file on partition sda2 (/home)
  765. Code:time dd if=/dev/sda2 of=/dev/null bs=1024k count=1000
  766.  
  767. Code:time dd if=/dev/zero bs=1024k count=1000 of=/home/1Gb.file
  768.  
  769. Code:hdparm -tT /dev/hda
Advertisement
Add Comment
Please, Sign In to add comment