Linux2010. 1. 11. 11:42
/proc/diskstats 파일은 linux kernel 2.6 부터 지원하는 것으로
hdd의 파일 입출력 속도를 볼 수 있다.

음.. FC6에서는 해보니, 1초 간격으로 갱신되는것 같은데
$ cat /proc/diskstats
   1    0 ram0 0 0 0 0 0 0 0 0 0 0 0
   1    1 ram1 0 0 0 0 0 0 0 0 0 0 0
   1    2 ram2 0 0 0 0 0 0 0 0 0 0 0
   1    3 ram3 0 0 0 0 0 0 0 0 0 0 0
   1    4 ram4 0 0 0 0 0 0 0 0 0 0 0
   1    5 ram5 0 0 0 0 0 0 0 0 0 0 0
   1    6 ram6 0 0 0 0 0 0 0 0 0 0 0
   1    7 ram7 0 0 0 0 0 0 0 0 0 0 0
   1    8 ram8 0 0 0 0 0 0 0 0 0 0 0
   1    9 ram9 0 0 0 0 0 0 0 0 0 0 0
   1   10 ram10 0 0 0 0 0 0 0 0 0 0 0
   1   11 ram11 0 0 0 0 0 0 0 0 0 0 0
   1   12 ram12 0 0 0 0 0 0 0 0 0 0 0
   1   13 ram13 0 0 0 0 0 0 0 0 0 0 0
   1   14 ram14 0 0 0 0 0 0 0 0 0 0 0
   1   15 ram15 0 0 0 0 0 0 0 0 0 0 0
   3    0 hda 108013 40509 5794964 3417656 108015 779595 7103102 61420792 0 2737052 64843120
   3    1 hda1 1076 2158 19 38
   3    2 hda2 147415 5792382 887883 7103064
 253    0 dm-0 147169 0 5791122 5857704 887853 0 7102824 1796618756 0 2736044 1802476620
 253    1 dm-1 70 0 560 1432 30 0 240 38624 0 6188 40056
   2    0 fd0 0 0 0 0 0 0 0 0 0 0 0
   9    0 md0 0 0 0 0 0 0 0 0 0 0 0

이런식으로 숫자만 잔뜩 나온다.

/proc/diskstats, giving some information (including device numbers) for each of the logical disk devices
[링크 : http://en.wikipedia.org/wiki/Procfs]

sysstat 패키지의 iostat 유틸리티
[링크 : http://elenoa.tistory.com/52]

3.2 /proc/diskstat => disk utilization, throughput (only 2.6 kernels)
[링크 : http://duo830210.tistory.com/45]

Field  1 -- # of reads completed
    This is the total number of reads completed successfully.

Field  2 -- # of reads merged, field 6 -- # of writes merged
    Reads and writes which are adjacent to each other may be merged for
    efficiency.  Thus two 4K reads may become one 8K read before it is
    ultimately handed to the disk, and so it will be counted (and queued)
    as only one I/O.  This field lets you know how often this was done.

Field  3 -- # of sectors read
    This is the total number of sectors read successfully.

Field  4 -- # of milliseconds spent reading
    This is the total number of milliseconds spent by all reads (as
    measured from __make_request() to end_that_request_last()).

Field  5 -- # of writes completed
    This is the total number of writes completed successfully.

Field  7 -- # of sectors written
    This is the total number of sectors written successfully.

Field  8 -- # of milliseconds spent writing
    This is the total number of milliseconds spent by all writes (as
    measured from __make_request() to end_that_request_last()).

Field  9 -- # of I/Os currently in progress
    The only field that should go to zero. Incremented as requests are
    given to appropriate struct request_queue and decremented as they finish.

Field 10 -- # of milliseconds spent doing I/Os
    This field is increases so long as field 9 is nonzero.

Field 11 -- weighted # of milliseconds spent doing I/Os
    This field is incremented at each I/O start, I/O completion, I/O
    merge, or read of these stats by the number of I/Os in progress
    (field 9) times the number of milliseconds spent doing I/O since the
    last update of this field.  This can provide an easy measure of both
    I/O completion time and the backlog that may be accumulating.

[링크 : http://www.mjmwired.net/kernel/Documentation/iostats.txt]


Posted by 구차니
Linux2010. 1. 11. 09:42
fork-exec로 실행한 프로그램의 리턴값을 받는 방법이다.
예를 들어 mount를 쉘에서 실행하고 그 결과값을 받고 싶을때 사용한다.

#include <sys/types.h>
#include <sys/wait.h>

WEXITSTATUS
(status)
    returns the exit status of the child. This consists of the least significant 16-8 bits of the status argument that the child specified in a call to exit() or _exit() or as the argument for a return statement in main(). This macro should only be employed if WIFEXITED returned true.

[링크 : http://linux.die.net/man/2/waitpid]

[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/2/waitpid]
Posted by 구차니
Linux2010. 1. 8. 16:26
# mount -t ntfs-3g

머.. 이런식으로 실행하면 자동으로 mount.ntfs-3g 라는 파일을 찾아서 실행을 한다.
처음에는 오 졸라 신기해!!! 하면서 뻘짓으로 ..

make 과정중에 나온 intall-exec-hook 인줄 알고 파고 들었다가 웬걸 ㄱ-
아무튼 install-exec-hook은 설치후 trigger 식으로 실행해주는 루틴을 의미할 뿐,
execution hook 이랑은 연관이 없다. (젠장 된장 미네랄!)
[링크 : http://wiki.kldp.org/wiki.php/DocbookSgml/Autotools-KLDP]

아무튼, linux kernel utils 를 검색해서 mount.c 를 열어보니 busybox와는 다른 확연한 차이가 있었다.
일단 exec() 패밀리와 fork()를 사용하는 루틴의 존재유무

util-linux-2.12r/mount/mount.c

static int
check_special_mountprog(const char *spec, const char *node, const char *type,
			int flags, char *extra_opts, int *status) {
  char mountprog[120];
  struct stat statbuf;
  int res;

  if (!external_allowed)
      return 0;

  if (type && strlen(type) < 100) {
       sprintf(mountprog, "/sbin/mount.%s", type);
       if (stat(mountprog, &statbuf) == 0) {
	    res = fork();
	    if (res == 0) {
		 const char *oo, *mountargs[10];
		 int i = 0;

		 setuid(getuid());
		 setgid(getgid());
		 oo = fix_opts_string (flags, extra_opts, NULL);
		 mountargs[i++] = mountprog;
		 mountargs[i++] = spec;
		 mountargs[i++] = node;
		 if (nomtab)
		      mountargs[i++] = "-n";
		 if (verbose)
		      mountargs[i++] = "-v";
		 if (oo && *oo) {
		      mountargs[i++] = "-o";
		      mountargs[i++] = oo;
		 }
		 mountargs[i] = NULL;
		 execv(mountprog, (char **) mountargs);
		 exit(1);	/* exec failed */
	    } else if (res != -1) {
		 int st;
		 wait(&st);
		 *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR);
		 return 1;
	    } else {
	    	 int errsv = errno;
		 error(_("mount: cannot fork: %s"), strerror(errsv));
	    }
       }
  }
  return 0;
}

위에 소스에서 보면

sprintf(mountprog, "/sbin/mount.%s", type);
res = fork();
execv(mountprog, (char **) mountargs);

mount -t ntfs 는 mount.ntfs 로
mount -t cifs 는 mount.cifs 로

-t type 으로 받은 인자를 이용하여 실행을 넘겨준다.



결론 : busybox에서는 mount 소스가 많이 간략화 되어있으므로
         표준 mount 파일에서 지원하는 mount.type 실행치환 기능을 지원하지 않는다.

[링크 : ftp://ftp.kernel.org/pub/linux/utils/util-linux/] 리눅스용 mount.c
[링크 : http://www.koders.com/c/fid840A8124E3B838F1EC7B690C35A7A6F9BF10277B.aspx] busybox용 mount.c

'Linux' 카테고리의 다른 글

linux에 연결된 HDD의 IO 상태보기  (0) 2010.01.11
fork-exec 종료시 리턴값  (0) 2010.01.11
ntfs-3g 크로스 컴파일 하기 (ntfs-3g cross compile)  (0) 2010.01.07
FUSE 넌 머냐?  (0) 2010.01.07
ntfs-3g at Tuxera  (0) 2010.01.06
Posted by 구차니
Linux2010. 1. 7. 14:23
이녀석.. 미운 4살도 아닌데 크로스 컴파일 대책이 제대로 안되어 있는지 한큐에 안된다 ㄱ-

i686 linux에서는 참 쉽게 한다.

./configure
make
make install

[링크 : http://www.tuxera.com/community/ntfs-3g-download/]

세줄 끝.. 참 쉽죠잉~



그.런.데 크로스컴파일은 악몽의 시작이었다.
sh4-linux 에서 크로스컴파일은 산넘어 산이었는데..

crash 1.
# export CC=gsh4-linux-gcc
# ./configure --host-=i686 --target=sh4-linux
..
checking if libtool supports shared libraries... no
checking whether to build shared libraries... no
..
# make
...
Making install in libntfs-3g
test -z "/usr/local/lib" || /bin/mkdir -p "/home/morpheuz/st7109/target/usr/local/lib"
 /bin/sh ../libtool   --mode=install /usr/bin/install -c  'libntfs-3g.la' '/home/morpheuz/st7109/target/usr/local/lib/libntfs-3g.la'
/usr/bin/install -c .libs/libntfs-3g.lai /home/morpheuz/st7109/target/usr/local/lib/libntfs-3g.la
/usr/bin/install -c .libs/libntfs-3g.a /home/morpheuz/st7109/target/usr/local/lib/libntfs-3g.a
chmod 644 /home/morpheuz/st7109/target/usr/local/lib/libntfs-3g.a
ranlib /home/morpheuz/st7109/target/usr/local/lib/libntfs-3g.a
libtool: install: warning: remember to run `libtool --finish /usr/local/lib'
make  install-exec-hook
test -z "/lib" || /bin/mkdir -p "/home/morpheuz/st7109/target/lib"
if [ ! "/lib" -ef "/usr/local/lib" ]; then \
/bin/mv -f "/home/morpheuz/st7109/target//usr/local/lib"/libntfs-3g.so* "/home/morpheuz/st7109/target//lib";  \
fi
/bin/mv: cannot stat `/home/morpheuz/st7109/target//usr/local/lib/libntfs-3g.so*': No such file or directory
make[3]: *** [install-exec-hook] Error 1
make[2]: *** [install-exec-am] Error 2
make[1]: *** [install-am] Error 2
make: *** [install-recursive] Error 1

머.. 간단해 보이지만 대책이 안선다 ㄱ-
일단은 so 파일도 생성하지 못하면서, so 파일을 옮길려고 하면서 죽는다..
미네랄!

아무튼 해결책은 아래와 같다.

Step 1. 혹시 모르니 liunx kernel의 FUSE 지원여부를 확인한다.
Step 2. 환경설정
# unset CC
# ./configure

# vi Makefile
# vi src/Makefile
# vi libntfs-3g/Makefile
# vi libfuse-lite/Makefile

에서
AR = ar
CC = gcc
CPP = gcc -E
CXX = g++
CXXCPP = g++ -E
ac_ct_CC = gcc
ac_ct_CXX = g++
를 찾아 sh4-linux- 접두를 붙여준다.

# vi libtool
에서
AR="ar"
LTCC="gcc"
CC="gcc"
OBJDUMP="objdump"
AS="as"
를 찾아 sh4-linux- 접두를 붙여준다.

이렇게 수정후에는 마음 편하게

# make

만약 make 시에 secaudio.c 에러가 발생하면
<attr/xattr.h> 를 <sys/xattr.h>로 수정한다.

# vi src/secaudit.c
 261 #ifdef HAVE_SETXATTR
 262 #include <sys/xattr.h>
 263 #else
 264 #warning "The extended attribute package is not available"
 265 #endif /* HAVE_SETXATTR */

아무래도 target 경로가 다를테니 DESTDIR을 넣고 목적지를 정해준다.

# make DESTDIR={target path} install

설치후 생성되는 파일목록
/sbin/mount.ntfs-3g -> /bin/ntfs-3g
/bin/ntfs-3g
/usr/local/bin/ntfs-3g.probe
/usr/local/bin/ntfs-3g.secaudit
/usr/local/bin/ntfs-3g.usermap

/lib/libntfs-3g.so -> libntfs-3g.so.71.0.0
/lib/libntfs-3g.so.71 -> libntfs-3g.so.71.0.0
/lib/libntfs-3g.so.71.0.0

/usr/local/share/man/man8/mount.ntfs-3g.8 -> ntfs-3g.8
/usr/local/share/man/man8/ntfs-3g.8
/usr/local/share/man/man8/ntfs-3g.probe.8
/usr/local/share/man/man8/ntfs-3g.secaudit.8
/usr/local/share/man/man8/ntfs-3g.usermap.8

/usr/local/lib/libntfs-3g.a
/usr/local/lib/libntfs-3g.la
/usr/local/lib/libntfs-3g.so -> /lib/libntfs-3g.so


실행결과
# mount -t ntfs-3g /dev/sda1 /root/sda1
mount: mounting /dev/sda1 on /root/sda1 failed: No such device

# ntfs-3g /dev/sda1 /root/sda1
WARNING: Deficient Linux kernel detected. Some driver features are
         not available (swap file on NTFS, boot from NTFS by LILO), and
         unmount is not safe unless it's made sure the ntfs-3g process
         naturally terminates after calling 'umount'. If you wish this
         message to disappear then you should upgrade to at least kernel
         version 2.6.20, or request help from your distribution to fix
         the kernel problem. The below web page has more information:
         http://ntfs-3g.org/support.html#fuse26

# mount
rootfs on / type rootfs (rw)
/dev/root on / type nfs (rw,noatime,vers=2,rsize=4096,wsize=4096,hard,nolock,proto=tcp,timeo=600,retrans=2,addr=192.168.10.10)
proc on /proc type proc (rw)
usbfs on /proc/bus/usb type usbfs (rw)
sysfs on /sys type sysfs (rw)
/dev/sda1 on /root/sda1 type fuse (rw,user_id=0,group_id=0,allow_other)

'Linux' 카테고리의 다른 글

fork-exec 종료시 리턴값  (0) 2010.01.11
mount.cifs mount.ntfs 등 자동연결의 비밀(?)  (0) 2010.01.08
FUSE 넌 머냐?  (0) 2010.01.07
ntfs-3g at Tuxera  (0) 2010.01.06
웹캠 VLC에서 테스트(Ubuntu 9.10)  (0) 2009.12.29
Posted by 구차니
Linux2010. 1. 7. 14:07

허전해서 붙이긴 했지만. 안드로메다 언어라 이해는 못하고.. (먼산)
이른대로 Filesystem을 Userspace에서 구현을 한다는 것이다.

일단, ntfs-3g 라는 ntfs 드라이버가 이 녀석을 사용하고,
그로 인해서 kernel에서 Filesystem in userspace support 를 켜주어야 했다.

[링크 : http://fuse.sourceforge.net/]
[링크 : http://en.wikipedia.org/wiki/Filesystem_in_Userspace]
Posted by 구차니
Linux2010. 1. 6. 13:54
음.. NTFS 드라이버라는데
신기하게(?)도 리부팅 없이, FC6 에서 바로 사용이 가능하다.

특이하게(?)도 FS는 mount 후에 fuseblk로 인식한다.

# mount -t ntfs-3g /dev/sda1 /mnt/old
# mount
/dev/hda5 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/hda3 on /var type ext3 (rw)
/dev/hdb on /home/samba type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /mnt/old type fuseblk (rw,allow_other,blksize=4096)

Stable Source Release 2009.11.14 << 소스 다운로드

[링크 : http://www.tuxera.com/community/ntfs-3g-download/]


Can I use NTFS-3G on Linux 2.4 kernels?

Yes. You need to use NTFS-3G 1.2506 or later and the FUSE kernel module from the FUSE 2.5.3 package. Please see more details in the FUSE README file.

[링크 : http://www.tuxera.com/community/ntfs-3g-faq/#kernel24]

Posted by 구차니
Linux2009. 12. 29. 23:01
  [CAMEL PC-100 : http://blog.danawa.com/prod/?prod_c=956003]
  [더불정보기술 X-LUK DBC-UP : http://blog.d

[링크 : http://minimonk.tistory.com/1084]

예전에 구매했던 웹캠 두마리를 Ubuntu 9.10을 설치하면서
VLC를 덤으로 설치하고 제대로 인식을 하나 테스트 해보았다.


잘된다. 그런데 기본설정으로 사용할때는 확실히 비싼게 좋다고, 더불정보기술의 녀석이
프레임도 빠르고, 부드럽게 나온다.

VLC 상에서 확인해 보면

X-LUK DBC-UP 는 JPEG 640x480
CAMEL PC-100 는 YUV2 640x480 로 나온다.

일단, 기본으로는 DBC-UP가 좋다.(음.. 하나더 지를까..)
그런데 더불꺼는 별도의 오디오도 없고, LED도 없다(없는게 나을지도?)

'Linux' 카테고리의 다른 글

FUSE 넌 머냐?  (0) 2010.01.07
ntfs-3g at Tuxera  (0) 2010.01.06
swapon을 이용하여 파일로 스왑하기  (0) 2009.12.23
DNS / Host Lookup 관련 파일  (0) 2009.12.22
OOM - Out of Memory  (2) 2009.12.15
Posted by 구차니
Linux/Ubuntu2009. 12. 26. 00:01
build-essential 을 설치해야지 gcc 및 각종 include 파일들이 설치된다.

추가적으로 추천하는 패키지는
meld
codeblocks
cvs/subversion

정도면 충분?!

[링크 : http://mwultong.blogspot.com/2006/10/gcc-c-ubuntu-linux-gcc-install.html]
Posted by 구차니
Linux2009. 12. 23. 11:11
스왑이 부족한데, 파티션 조정은 힘드니 파일로 스왑을 하는 방법이 있다고 한다.
dd if=/dev/zero of=/swapfile bs=1024 count=1000
mkswap /swapfile
swapon /swapfile
dd 로 생성할때는 bs는 Blocksize로 byte 단위이다.

[링크 : http://ask.nate.com/qna/view.html?n=8735836]
[링크 : http://linux.die.net/man/8/swapon]


스왑파일은 어디서 생성하던 상관은 없지만,
NFS Client 일 경우에는, 외부 디스크에만 스왑이 되는 듯한 현상이 발생했다.

# swapon swapfile
swapon: swapfile has holes
swapon: swapfile: Invalid argument
안될때는 이렇게 나오고(NFS 상의 디렉토리에서 수행)

# swapon swapfile
Adding 992k swap on swapfile.  Priority:-1 extents:1 across:992k
되면 이렇게 곱게 나와주신다. (USB 로 파일 이전후 시도)


swap filesystem을 지원하지 않아서 그런것 같다는 말도 있긴 하지만,
단순하게 디스크를 옮김으로서 해결이 된것봐서는, swapfile의 위치 제약이 존재하는 듯 하다.
[링크 : http://www.0x61.com/forum/busybox-linux-f110/filesystem-v1-10-0-swapon-swapfile-has-holes-blocksize-t50097.html]

+
2021.01.18
swapon 으로 상황을 볼 수 있다.

[링크 : https://www.snoopybox.co.kr/1964]

'Linux' 카테고리의 다른 글

ntfs-3g at Tuxera  (0) 2010.01.06
웹캠 VLC에서 테스트(Ubuntu 9.10)  (0) 2009.12.29
DNS / Host Lookup 관련 파일  (0) 2009.12.22
OOM - Out of Memory  (2) 2009.12.15
Linux 에서 malloc 으로 할당된 memory 크기를 알 수 있는 방법  (2) 2009.12.14
Posted by 구차니
Linux2009. 12. 22. 17:49
resolv.conf 는 DNS 서버의 아이피가 들어감
nsswitch.conf 는 호스트 이름을 resolve할 순서를 정의함
hosts 는 static 한 resolve 이름을 정의한다. (예를 들어 리눅스 로컬 서버들끼리의 alias)

삼바에서는
lmhossts 파일을 통해 할 수 있고,
smb.conf 에서 resolve할 순서를 정의할 수 있다.

[링크 : http://linux.die.net/man/5/resolv.conf]
[링크 : http://linux.die.net/man/5/nsswitch.conf]
[링크 : http://linux.die.net/man/5/hosts]
[링크 : http://linux.die.net/man/5/hosts.allow]
[링크 : http://linux.die.net/man/5/hosts.deny]

[링크 : http://linux.die.net/man/7/samba]
[링크 : http://linux.die.net/man/5/smb.conf]
[링크 : http://linux.die.net/man/5/lmhosts]
Posted by 구차니