'2014/05'에 해당되는 글 3건

  1. 2014.05.25 Windows7 설치후 리눅스에서 ExFat인식 문제 해결방법 2
  2. 2014.05.20 mplayer 이어서 보기 스크립트. 2
  3. 2014.05.11 virtualbox freezing 문제 해결.

Windows7 설치후 리눅스에서 ExFat인식 문제 해결방법

외장하드에 Windows7을 설치 (http://snoopybox.co.kr/1362)를 한 이후에 이상증세가 나타나서 포스팅.


(결론부터 말해서, 이 이상 증상이 뭔가 하면.. 일반디스크(외장 디스크 말고요)의 exfat이 리눅스에서 마운트가 안된다는 사실입니다.


윈도우에서 직접 exfat의 드라이브가 페이지를 사용하지 않도록 설정 해야 합니다. 그래야 리눅스에서 exfat을 사용할수 있어요.)


다음은 삽질기-


systemd에서 에러먹고 이머전시 모드로 넘어가길래, 처음에는 '이놈의 아치리눅스 또 이짓거리 시작하는구나' 싶었는데 패키지 문제인줄 알았답니다.


여튼 보라는데로 로그를 봤는데 "/bin/plymouth not found" 비슷한 오류를 내면서 뻗어버리길래, 실제로 해당 경로에 그 파일이 없는겁니다...


그래서 이 패키지를 설치하면 되겠거니... 했지만 설마해서 구글링을 좀 해보니까,


"ㄴㄴ 그 메세지는 상관없음. 마운트에 문제가 있으면 그럼. 그러니깐 님 /etc/fstab이나 까보셈" 이라는 bbs 답변이 올라온것을 찾아내고,


fstab을 찾아서 이것저것 막아가며 리부트 몇번 해 보니까 exfat만 마운트 안하게 해놓으니깐 또 잘 돌아가네여. 그래서 여기서 촉이 왔죠.


"아 내가 방금 깐 윈도우가 원인이구나"


그리고 리눅스에서 혹시모르니까 수동으로 마운트 해봤는데, 그래도 실패. 대신 뜻있는 에러 메세지를 얻었네요.


에러메세지가 정확이 무엇인지는 기억나지 않습니다만, 대충 "pagefile.sys크기가 0이 아니네? 에러. 나 파업할거야." 뭐 이런 내용이였지요.


그래서 윈도우로 부팅한다음, (숨김파일을 해제해야 보입니다... 나쁜 윈도우...) exfat드라이브를 확인해 보니, pagefile.sys가 딱!


그래서


'제어판 → 시스템 및 보안 → 시스템 → 고급시스템 설정' '시스템속성' 에서 '고급'탭 선택


'성능'의 '설정'버튼을 눌러서 '성능옵션'을 띄운다음 '고급'탭의 '가상메모리'의 변경 버튼을 누릅니다.


만약, "모든 드라이브에 대한 페이징 파일 크기 자동 관리'가 체크되었다면 해제하고,


바로 아래의 리스트에서 ExFat 드라이브를 선택한후, "페이징 파일 없음"을 선택하고 옆에 "설정"을 꼭 눌러 주세요. 그리고 확인.


(그냥 바로 확인 버튼을 누르면 적용되지 않습니다! "설정"을 누르고 확인을 눌러야 해요! 주의!! )


그다음 재부팅해서 리눅스로 들어간다음 일단 ctrl+d눌러서 쉘로 빠져서 $systemctl default 해주면 이제 에러를 안보여주는 systemd를 볼수 있어요.



ps; 근데 windows8은 이런 증상 작동 안하드만. windows7은 이러네여. 신기해라... 여튼 리눅스 유저로써는 참으로 짜증나는 짓거리임에 틀림없어요 이거...



mplayer 이어서 보기 스크립트.

몇일동안 써 봤는데 별 문제는 없네요.


(뭐 생기면 고치면 되고...)


원리를 간단하게 설명하자면.


1,mplayer를 터미널상에서 재생시키면, 현재 재생중인 위치가 가장 마지막 위치에 나옵니다.


2, 재생전에 로그파일에 정보가 있는지 확인하고, 있으면 그곳을 시작위치로 저장해서 mplayer를 재생.


3, 이후 계속 출력 메세지를 받아놓고,


4, mplayer가 종료되면 로그의 가장 마지막줄을 읽어서 끝난 위치를 알아내는 거죠.


5, 그리고 난 다음, 로그파일에 정보가 없으면 새로운 로그 라인에 (기록초, 파일경로) 추가, 있으면 수정합니다.


(사실 원래는 중간에 메세지를 가로채서 파이프로 보내려고 했습니다만, 아무래도 뻘짓같아서...  포기하고 있다가 AUR에 mplayer-resumer(https://aur.archlinux.org/packages/mplayer-resumer/) 패키지를 보고 힌트를 얻어서 작성. (대체 왜 나는 쓸데없이 복잡한 방법을 생각해 냈을까?)


동영상 길이도 검사해서 맨뒷부분에서 exit시에는 기록을 하지 않게 만들어 놓았습니다.


저는 mplayer를 slave mode(외부에서 파이프로 mplayer 제어) 로도 사용하기 때문에 파이프를 설정하는 옵션도 들어갔습니다만, 필요없으면 없애주세요.


길이만 길다뿐이지 별거 아닙니다. 그럼 코드.


#!/bin/bash


# 필요 패키지 : bash, mplayer, ffmpeg, perl, 기타 쉘 관련 유틸리티
MPLAYER_PATH="/home/lowid/bin/mplayer"
MPLAYER_PIPE_PATH="/tmp/mplayer_pipe"
MPLAYER_LOG_FILEPATH="/share/ani/.mplayer_position.log"

# 키 후킹법 => 실패.
#while [ 1 ];do read -n 1 CMD >/dev/null;HEX="$(echo -n "$CMD" | hexdump -e \"%d\")";echo "key_down_event $HEX" > /tmp/mplayer_pipe;done
export MPLAYER_STATUS_OK_END=0
export MPLAYER_STATUS_OK_PLAYING=1
export MPLAYER_ERROR_NOT_PLAY_FILE=2
export MPLAYER_ERROR_LOG_POSITION_GET=3
export MPLAYER_ERROR_PLAYING=4

# mplayer에서 재생할 파일경로와 옵션을 분리해 냅니다
# 주의 : 각 인자를 확장자를 기준으로 분류합니다. (파싱 오류 가능성 있음!)
function Option_Parse()
{
    local Param=""
    unset OPTION_PARSE_RETURN_FILEPATH
    unset OPTION_PARSE_RETURN_OPTIONS

    for Param in "$@";do
        if [ "$(echo "$Param" | grep -E "\.mpg|\.wvx|\.rmvb|\.avi|\.mkv|\.wmv|\.mp4")" ];then

            OPTION_PARSE_RETURN_FILEPATH="$(realpath "$Param")"
        else
            OPTION_PARSE_RETURN_OPTIONS=""$OPTION_PARSE_RETURN_OPTIONS" "$Param""
        fi
    done
}

function Mplayer_Play_Duration()
{
    local Play_filepath="$1"
    local Play_file_duration=""
    local Hour=0
    local Minute=0
    local Second=""
    unset MPLAYER_PLAY_DURATION_RETURN_SECOND

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    Play_file_duration="$(ffmpeg -i "$Play_filepath" 2>&1 | grep '^\s*Duration: [0-9][0-9]:[0-9][0-9]:[0-9][0-9]' | perl -pe 's/^.*?\: //g,s/\..*$//g')"
    Hour="$(echo "$Play_file_duration"   | cut -d ':' -f1 | perl -pe 's/^0//g')"
    Minute="$(echo "$Play_file_duration" | cut -d ':' -f2 | perl -pe 's/^0//g')"
    Second="$(echo "$Play_file_duration" | cut -d ':' -f3 | perl -pe 's/^0//g')"

    MPLAYER_PLAY_DURATION_RETURN_SECOND=$(($Hour * 60 * 60 + $Minute * 60 + $Second))

    return 0
}

function Mplayer_Log_Position_Get()
{
    local Play_filepath="$1"
    local Log_filepath="$2"
    local Log_play_file_line=""
    MPLAYER_POSITION_GET_RETURN_PLAY_SECOND=0

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ ! -f "$Log_filepath" ];then
        touch "$Log_filepath"
    fi

    Log_play_file_line="$(fgrep -n "$Play_filepath" "$Log_filepath" | cut -d ':' -f1 2>/dev/null)"
   
    if [ -n "$Log_play_file_line" ];then
        MPLAYER_POSITION_GET_RETURN_PLAY_SECOND="$(sed -n "$Log_play_file_line"'p' "$Log_filepath" | cut -d ' ' -f1)"
    fi

    return 0
}

function Mplayer_Log_Position_Set()
{
    local Play_filepath="$1"
    local Play_second="$2"
    local Log_filepath="$3"
    local Log_play_file_line=""
    local Log_play_file_data=""
    local Temp_filepath="/tmp/mpp_$RANDOM"

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ -z "$Play_second" ];then
        return 2
    fi

    if [ ! -f "$Log_filepath" ];then
        return 3
    fi

    Log_play_file_line="$(fgrep -n "$Play_filepath" "$Log_filepath" | cut -d ':' -f1 2>/dev/null)"
   
    # 없으면 뒤에 쓰고, 없으면 치환.
    if [ -z "$Log_play_file_line" ];then
        echo "$Play_second" "$Play_filepath" >> "$Log_filepath"
    else
        Log_play_file_data=""$Log_play_file_line"c "$Play_second" "$Play_filepath""
        sed -e "$Log_play_file_data" "$Log_filepath" > "$Temp_filepath"
        mv -f "$Temp_filepath" "$Log_filepath" 2>/dev/null
    fi

    return 0
}

function Mplayer_Log_Position_Delete()
{
    local Play_filepath="$1"
    local Log_filepath="$2"
    local Log_play_file_line=""
    local Temp_filepath="/tmp/mpp_$RANDOM"

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ ! -f "$Log_filepath" ];then
        return 2
    fi

    Log_play_file_line="$(fgrep -n "$Play_filepath" "$Log_filepath" | cut -d ':' -f1 2>/dev/null)"

    if [ -z "$Log_play_file_line" ];then
        return 3
    fi

    sed -e "$Log_play_file_line"'d' "$Log_filepath" > "$Temp_filepath"
    mv -f "$Temp_filepath" "$Log_filepath" 2>/dev/null

    return 0
}

function Mplayer_Play_Continue()
{
    local Options="$1"
    local Play_filepath="$2"
    local Play_position_second="$3"
    local Play_backward_second="$4"
    local Mplayer_end_second=""
    local Mplayer_start_position_second=""
    unset MPLAYER_PLAY_RETURN_POSITION

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ -z "$Play_position_second" ];then
        return 2
    fi

    if [ -z "$Play_backward_second" ];then
        return 3
    fi

    # mplayer 경로는 전역임 주의, -ss옵션에 0이 들어가도 상관 없다
    Mplayer_end_second="$("$MPLAYER_PATH" $Options -ss "$Play_position_second" "$Play_filepath" 2>/dev/null | strings | tail -2 | egrep '^A:' | perl -pe 's/^A:\s*//g,s/ V:.*//g')"

    if [ -z "$Mplayer_end_second" ];then
        return 4
    fi

    Mplayer_start_position_second="$(echo "$Mplayer_end_second" | cut -d '.' -f1)"
    if [ -z "$Mplayer_start_position_second" ];then
        return 5
    fi

    MPLAYER_PLAY_RETURN_POSITION="$(($Mplayer_start_position_second - $Play_backward_second))"
}

function Mplayer_Pipe()
{
    local Play_filepath="$1"
    local Pipe_path="$2"
    local Pipe_option=""
    unset MPLAYER_PIPE_RETURN_OPTION

    # mkv는 fifo 사용이 불가능한듯함
    if [ -z "$(echo "$Play_filepath" | grep \.mkv)" ];then
        if [ "$(file "$Pipe_path" | cut -d ' ' -f2)" != "fifo" ];then
            mkfifo "$Pipe_path"
        fi

        Pipe_option="-slave -input file="$Pipe_path""
    fi

    MPLAYER_PIPE_RETURN_OPTION="$Pipe_option"
}

function Mplayer()
{
    local Play_filepath=""
    local Options=""
    local Played_position_second=""
    local Restart_backword_second=2
    local Playing_position_second=""
    local Playing_file_duration=""
    local Restart_last_second=10
    local Return_succeed_value=0

    Option_Parse "$@"
    Play_filepath="$OPTION_PARSE_RETURN_FILEPATH"
    Options="$OPTION_PARSE_RETURN_OPTIONS"

    if [ -z "$Play_filepath" ];then
        return $MPLAYER_ERROR_NOT_PLAY_FILE
    fi

    Mplayer_Pipe "$Play_filepath" "$MPLAYER_PIPE_PATH"
    Options=""$Options" "$MPLAYER_PIPE_RETURN_OPTION""

    Mplayer_Log_Position_Get "$Play_filepath" "$MPLAYER_LOG_FILEPATH"
    if [ $? != 0 ];then
        return $MPLAYER_ERROR_LOG_POSITION_GET
    fi

    Played_position_second="$MPLAYER_POSITION_GET_RETURN_PLAY_SECOND"

    Mplayer_Play_Continue "$Options" "$Play_filepath" "$Played_position_second" "$Restart_backword_second"
    if [ $? != 0 ];then
        return $MPLAYER_ERROR_PLAYING
    fi

    Playing_position_second="$MPLAYER_PLAY_RETURN_POSITION"

    # 동영상의 재생 길이를 알때에만 기록을 한다.
    Mplayer_Play_Duration "$Play_filepath"
    if [ $? = 0 ];then
        Playing_file_duration="$MPLAYER_PLAY_DURATION_RETURN_SECOND"

        if [ $(($Playing_position_second + $Restart_last_second )) -lt "$Playing_file_duration" ];then
            Mplayer_Log_Position_Set "$Play_filepath" "$Playing_position_second" "$MPLAYER_LOG_FILEPATH"
            Return_succeed_value=$MPLAYER_STATUS_OK_PLAYING
        else
            Mplayer_Log_Position_Delete "$Play_filepath" "$MPLAYER_LOG_FILEPATH"
            Return_succeed_value=$MPLAYER_STATUS_OK_END
        fi
    fi

    return $Return_succeed_value
}


따로 설정할수 있는 부분은 전역으로 빼놨으니까 수정하시기 편할거에요.


ps; ~/.bashrc에 다음과 같이 쓰시길 추천. 아니면 따로 빼서 쓰시던지요.

alias mp='. /path/Mplayer.sh;Mplayer'




virtualbox freezing 문제 해결.

저번에 올린 가상머신 문제와 같은 문제가 리눅스 박스에서 감지가 되었다.


일단 VirtualBox를 실행시키는데에는 문제가 없으나, 가상머신 이미지로 실제로 구동하면 문제가 발생.


창은 뜨는데 "starting virtualbox machine...."하고 맛이 가버리는 문제의 이 현상.


http://lowid.tistory.com/entry/Linux-Kernel-3xx-%EC%97%90%EC%84%9C-Virtualbox%EB%8F%8C%EB%A6%B4%EC%8B%9C-%EC%83%9D%EA%B8%B0%EB%8A%94-%EB%AC%B8%EC%A0%9C%EC%A0%90-%ED%95%B4%EA%B2%B0


증상은 비슷했지만, 원인은 달랐는데...

이번 문제는 VirtualBox.xml 파일에 있었다. (보통은 ~/.Virtualbox이 밑에 있음)


가상머신의 CD-ROM에 외부 저장장치(외장하드라던가, USB 드라이브)에 들어 있는 iso파일 같은게 물려 있으면 문제가 발생한다.


      <ExtraDataItem name="GUI/RecentFolderCD" value="/home/lowid/media/ExData/Game ......
      <ExtraDataItem name="GUI/RecentListCD" value="/home/lowid/media/ExData/Game ......


VirtualBox.xml 파일을 열어서, 현재 시스템 상에서 죽은 연결(위와 같이 외장하드에 물려있는)이 있는 라인을 삭제 해주고 가상머신을 시작해 주자.


뭐, 실제 파일 편집해보면, 위에 주석으로 오버라이팅하니까 막 수정하지 말라고 하는데 어짜피 가상머신 끄고 고치면 상관 없으므로 걍 무시하고 고쳐주면 된다. 언제는 뭐 이런거 그렇게 신경 쓰기나 했나 뭐(...)


오라클은 이렇게 단순한 오류도 처리 안하고 뭐하는거냐 대체.....


prev 1 next